WP 固定ページ内子ページ一覧


<?php
    $children= get_pages('child_of='.$post->ID);
    if( !empty( $children ) ):
?>
<ul>
<?php
    $parent_id = get_the_ID();
    $args = array(
        'posts_per_page' => -1,
        'post_type' => 'page',
        'orderby' => 'menu_order',
        'order' => 'ASC',
        'post_parent' => $parent_id,
    );
    $common_pages = new WP_Query( $args );
    if( $common_pages->have_posts() ):
    while( $common_pages->have_posts() ): $common_pages->the_post();
?>
    <li><a href="">
        <?php the_title(); ?>
    </a></li>
<?php
    endwhile;
    wp_reset_postdata();
    endif;
?>
</ul>

WP 固定ページ内孫ページ一覧
孫一覧を取得するものと最初の指定が違うだけです。
この少しの差を見つけるのに苦労しました・・・

WEB,WP

Posted by admin