Display subpages under parent page as a list within a loop

First set your arguments(settings)

 $args = array(
        'post_parent' => get_the_ID(),
        'post_type'   => 'page',
        'numberposts' => -1,
        'post_status' => 'publish'
    );

    $children = get_children( $args, $output ); 

then you can use something like this

<?php if (!empty($children)):?>
    <ul class="row">
        <?php foreach($children as $dest){
            $permalink = get_permalink($dest->ID);
            echo "<li class="col-sm-4"><a href="https://wordpress.stackexchange.com/questions/254608/{$permalink}">" . $dest->post_title . "</li>";
        }?>
    </ul>
<?php endif;?>

For more info
https://codex.wordpress.org/Function_Reference/get_children

Leave a Comment