WordPress.org

Support

Support » Plugins and Hacks » Hacks » Showing a page and its children

Showing a page and its children

  • Okay, hopefully this will be easier than the other questions I’ve been asking lately…

    I have a custom post type which is hierarchical, and I want to create a query that shows the current post AND all of its children. The following code does what I want, but it only shows the post’s children:

    <?php query_posts(array('showposts' => 5, 'post_parent' => 128, 'post_type' => 'portfolio'));
    
    while (have_posts()) { the_post(); ?>
             <h3 class="entry-title"><?php the_title(); ?></h3>
    <?php }
    
    wp_reset_query();  // Restore global post data ?>

    How can I modify this so that the parent post is included in the loop along with the children?

  • The topic ‘Showing a page and its children’ is closed to new replies.
Skip to toolbar