1
在WordPress的页面上,我想显示该页面的所有儿童。这个工作在这样的时刻:WordPress的:计数子页面
<?php
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'post_parent' => $post->ID,
'order' => 'ASC',
'orderby' => 'menu_order'
);
$parent = new WP_Query($args);
if ($parent->have_posts()) : ?>
<?php while ($parent->have_posts()) : $parent->the_post(); ?>
<div id="parent-<?php the_ID(); ?>" class="parent-page">
<h1><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
</div>
<?php endwhile; ?>
我想的是,循环的计数我的帖子,并打印在div的数量,从1开始,例如:
<div class="child1">
Title of first child
</div>
<div class="child2">
Title of second child
</div>
<div class="child3">
Title of third child
</div>
你有什么建议?
目前尚不清楚您需要什么帮助。看起来好像你只需要修改循环内的标记? – George