I need to display the content of child pages on a parent page in Wordpress (not posts). This works, displays the title of the child page, but I can not get the content to display. (last 2 lines)
global $post;
$args = array( 'numberposts' => 1, 'category_name' => 'foundation','post__in' => get_option( 'sticky_posts' ) );
$the_query = new WP_Query( $args );
while ($the_query -> have_posts()) {
$the_query->the_post();
?>
<article class="lead">
<h1><?php the_title(); ?></h1>
<section>
<?php the_content(); ?>
</section>
</article>
<?php
}
$newQuery = new WP_Query();
$all_pages = $newQuery->query(array('post_type' => 'page'));
$foundation = get_page_by_title('Foundation');
$foundation_children = get_page_children($foundation->ID, $all_pages);
query_posts('pagename=foundation');
while(have_posts()) {
the_post();
the_title();
the_content();
}
foreach($foundation_children as $tc) {
echo $tc->post_title; // this works
echo $tc->the_content; // this doesn't
}
The correct variable is post_content
.
Try echo $tc->post_content;
Reference: http://codex.wordpress.org/Class_Reference/WP_Post
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.