我不完全确定我是否正确地理解了你的问题,因为“这不是一个可选的部分”,但是。。。
您将获得ID为2的页面的子页面,因此看起来您希望显示该页面的标题。如果是这样,那么此代码将解决您的问题:
<?php
$args = array(
\'post_type\' => \'page\', //write slug of post type
\'posts_per_page\' => -1,
\'post_parent\' => \'2\', //place here id of your parent page
\'order\' => \'ASC\',
\'orderby\' => \'menu_order\'
);
$childrens = new WP_Query( $args );
if ( $childrens->have_posts() ) :
?>
<div class="content">
<h2 class="big grid_3"><?php echo get_the_title(2); ?></h2>
<div class="grid_6 right">
<?php while ( $childrens->have_posts() ) : $childrens->the_post(); ?>
<div class="grid_2 left" id="teaser" >
<p class="subtitle"></p>
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
<a class="cta_light" href="<?php the_permalink(); ?>">Mehr erfahren</a>
</div>
<?php endwhile; // <- I had to move that, it was in wrong place so you were closing more divs than you were opening in that loop ?>
</div>
</div><!-- .content -->
<?php
endif;
// wp_reset_query(); <- there is no point in resetting query - you haven\'t changed it
wp_reset_postdata(); // on the other hand you should reset postdata
?>
另外,看看我的评论——我不得不对你的代码做一些更改,因为它生成了错误的HTML输出。