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; ?>
私が欲しいのはループが私の記事をカウントし、例えば、1から始まる、DIVに番号を印刷していることである:
<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