displaying parent & child pages
-
I have this code that will let me display child-pages on parent-page with featured image but the thing is i want it to display it on the child-pages as well and also to include the parent page in the same list.
I also want to make sure if there are no child pages the code won’t execute anything.I have been stuck on this for some time now any help would be great = )
Thanks
<?php $child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID." AND post_type = 'page' ORDER BY menu_order", 'OBJECT'); ?> <?php if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?> <div class="child-thumb"> <?php echo get_the_post_thumbnail($pageChild->ID, 'thumbnail'); ?> <a href="<?php echo get_permalink($pageChild->ID); ?>" rel="bookmark" title="<?php echo $pageChild->post_title; ?>"><?php echo $pageChild->post_title; ?></a> </div> <?php endforeach; endif; ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘displaying parent & child pages’ is closed to new replies.