WordPress: Call Grandchildren of all Children from Single Parent Page

Ummmm yeaaah.

I’m working on a WordPress eCommerce site. Want to have a top level parent page called “Shop” with Child pages: “Product Type 1”, “Product Type 2″, Product Type 3”.

Read More

Each of the three second level children will have a long list of products (as third level children).

Here is my issue: When the top level “Shop” page is selected, I want to query ALL of the grandchildren. I also want to exclude the second level children from the list…those pages only exist as templates and for SEO reasons.

Here is what I’ve used in the past when calling child pages:

query_posts("post_parent=48&post_type=page&orderby=title&order=asc");

Where post_parent=48 is the top level page’s ID. Any suggestions?

Related posts

Leave a Reply

1 comment

  1. This is what i ended up doing for this, works great for my situation:

    if ( (is_page('Shop')) or (is_page('Product Type 1')) ) {
    
    query_posts("showposts=100&post_parent=34&post_type=page&orderby=title&order=asc");
    
    while(have_posts()) {
    
    the_post(); // vital 
    

    Where post_parent=34 is the post ID of Product Type 1. Then:

    wp_reset_query(); 
    
    if ( (is_page('Shop')) or (is_page('Product Type 2')) ) {
    
    query_posts("showposts=100&post_parent=48&post_type=page&orderby=title&order=asc");
    
    while(have_posts()) {
    
    the_post(); // vital 
    

    Where post_parent=48 is the post ID of Product Type 2…And so forth for all Product Types.

    Not sure if this is the Best way of setting this up, but was pretty simple and…it works 😉