I searched around and found some code that allowed me to pull the title, excerpt, and an image using a custom field of a “subsection” (child) on a “section” (parent) page. The problem I am having is that when add this loop to the pages.php template it spits out the subsection (child) snippets on EVERY section page. What I am trying to accomplish is to have one the original parent show the snippets from it’s child(ren). Each parent will have different children, and the ones without will show none.
Here is what I am currently using:
<?php $pageChildren = $wpdb->get_results(“SELECT * FROM $wpdb->posts WHERE post_parent =7 AND post_type = ‘page’ ORDER BY menu_order”, ‘OBJECT’); ?>
<?php if ( $pageChildren ) : foreach ( $pageChildren as $pageChild ) : setup_postdata( $pageChild ); ?>
Any help would be greatly appreciated. thanks.
- The topic ‘Display child info ONLY on related parent page’ is closed to new replies.