大体はカスタム投稿とかで実装しますが、たまに固定ページのまま下層の子ページ一覧を表示したい時ありますよね。
そんな時は専用のphpテーマファイルを用意すれば大丈夫です。
例えばスラッグ「items」という固定ページに子ページ一覧を表示したい時は、「page-items.php」に下記ループを書いてあげます。
<?php
$parent_id = get_the_ID();
$args = [
'posts_per_page' => -1,
'post_type' => 'page',
'orderby' => 'date',
'order' => 'ASC',
'post_parent' => $parent_id,
];
$my_query = new WP_Query($args); ?>
<?php if ($my_query->have_posts()) : ?>
<ul class="p-top-case-lists">
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li class="p-top-case-item">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<p class="p-top-case-item-desc">
<?php echo get_the_excerpt(); ?>
</p>
</li>
<?php endwhile; ?>
</ul>
<?php endif; wp_reset_postdata(); ?>
「$parent_id = get_the_ID(); 」で固定ページ「items」のidを取得して、「’post_parent’ => $parent_id, 」でループの親になるidを設定してる感じです。
「WP_Query」でサブループを回すことに慣れていればすこぶる簡単ですね!