get_pages – Show grandchildren pages but exclude parent
-
Hi
I am wondering if this is possible. Basically my pages are set up like this:
Projects (main parent page)
– Category 1 (sub-parent page)
— Project 1 (grandchild page)– Category 2
— Project 2
— Project 3– Category 3
— Project 4
— Project 5
— Project 6…etc
I want to show all pages within Projects (ID=2) but exclude the Category pages. ie. only show all of the grandchildren / ‘projects’.
My current code is:
<?php $mypages = get_pages( array( 'child_of' => '2', 'sort_column' => 'post_date', 'sort_order' => 'desc' ) ); foreach( $mypages as $page ) { $content = $page->post_content; if ( ! $content ) // Check for empty page continue; $content = apply_filters( 'the_content', $content ); ?> <h2><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?><?php echo $page->post_title; ?></a> </h2> <?php } ?>
…but this shows the Category pages as well. Any way that I can exclude these pages?
Thanks
Alice
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘get_pages – Show grandchildren pages but exclude parent’ is closed to new replies.