This question already has an answer here:
I created a hierarchical custom post type called "films." It is hierarchical so it can have children elements.
I am using a conditional statement in my single-films.php to show different content for the parent page from the children pages like so:
<?php if( $post->post_parent != 0 ) {
echo "Press Page";
} else {
echo "Film Page";
} ?>
In the condition that the page is a child, I want to use a custom wordpress loop, that loops through it's parents content. I am guessing I will need to use a loop similar to this (for the children):
<?php $posts = query_posts('&post_parent=0'); ?>
<?php while(have_posts()) : the_post(); ?>
wordpress content
<?php endwhile; ?>
This isn't working correctly. I need it to pull any content I wish (custom field, title, featured image, etc) from it's parent. Any idea how I can modify this loop to pull content from it's parent?
query_posts, it should never be used, it will only cause you pain, headaches, nausea, and horrible migraine induced vomitting – Tom J Nowell Sep 30 '12 at 3:07