1

so i have a custom post type with hierarchical structure. Looks like this:

top level 1
   - child 
      -- grand child
      -- grand child
   - child
      -- grand child
top level 2
   - child 
      -- grand child
      -- grand child
   - child
      -- grand child
top level 3

and so on.

I need a query with top level id as a base and query through all child and grand child pages of that top level page?

I know ther is post_parent arg, but it wont query grand childs... I know I can second query childs for grand childs... but i dont want that. I need 1 query with all the other parameters, and with proper pagination count. any ways to achive that?

thanks

3
  • 1
    This is not really going to be feasible with a single query. What problem are you trying to solve? There might be an alternative approach. Aug 23 at 13:03
  • 2
    Are you sure you didn't actually want a taxonomy? If you need to group posts together you should use a taxonomy term, you can't ask WP_Query and the functions built on top of it for grandparent relationships, that's not how the table was designed or how the data is stored. Doing this requires multiple queries, but you shouldn't need to be able to do this. What problem is this going to solve for you?
    – Tom J Nowell
    Aug 23 at 13:13
  • So this is just a product catalog. we have a category (top level) and than in that we have either a product or a system of products with single products in it. I want to display prodyctst and systems and for that i use double query, but i also want to display product with specific function and for that i need to query all product in category ommiting the system..
    – Piotr
    Aug 23 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.