首先,您需要查询子页面:
$pageargs = array(
\'numberposts\' => -1,
\'orderby\' => \'menu_order\',
\'order\' => \'ASC\',
\'post_type\' => \'page\',
\'post_parent\' => $post->ID
);
$childpages = get_posts( $pageargs );
然后,您需要创建自定义循环:
foreach ( $childpages as $childpage ) {
// Output whatever you want here, such as:
?>
<h2><?php echo $childpage->post_title; ?></h2>
<?php echo $childpage->post_exerpt; ?>
<?php }
但请注意,默认情况下,页面不支持摘录。因此,您需要在
functions.php
:
// Add Excerpt to Pages
add_post_type_support( \'page\', \'excerpt\' );
那么,你应该准备好了。