你的问题有点不清楚。。。我想你想问的是如何显示该帖子的父内容。。。还有每个孩子的内容?
尝试以下操作:
对于家长(假设您的内容就是标题)
<?php if (have_posts()) : ?>
<h1><?php the_title(); ?></h1>
<?php while (have_posts()) : the_post(); ?>
为了孩子们
<?php
global $post;
$child_pages_query_args = array(
\'post_type\' => \'your-custom-type\',
\'post_parent\' => $post->ID,
\'orderby\' => \'menu_order\'
);
$child_pages = new WP_Query( $child_pages_query_args );
if ( $child_pages->have_posts() ) : while ( $child_pages->have_posts() ) : $child_pages->the_post();
?>
<div>SOME CHILD CONTENT</div>
结束子项
<?php
endwhile; endif;
wp_reset_postdata();
?>
结束父级
<?php endwhile; endif; ?>
整个过程将如下所示:
<?php if (have_posts()) : ?>
<h1><?php the_title(); ?></h1>
<?php while (have_posts()) : the_post(); ?>
<?php
global $post;
$child_pages_query_args = array(
\'post_type\' => \'your-custom-type\',
\'post_parent\' => $post->ID,
\'orderby\' => \'menu_order\'
);
$child_pages = new WP_Query( $child_pages_query_args );
if ( $child_pages->have_posts() ) : while ( $child_pages->have_posts() ) : $child_pages->the_post();
?>
<div>SOME CHILD CONTENT</div>
<?php
endwhile; endif;
wp_reset_postdata();
?>
<?php endwhile; endif; ?>