I’m outlining a solution for you, it uses get_children
to determine if there are any, then conditionally sets up the post id $p_id
for the child_of
parameter, so that the list of child pages from a certain parent always can be shown, by making use of wp_list_pages()
.
Code:
function wpse125273_child_page_nav() {
global $post;
$args = array(
'post_parent' => $post->ID,
'post_type' => 'page',
'post_status' => 'publish'
);
$children = get_children( $args );
if ( empty( $children ) ) {
$p_id = $post->post_parent;
} else {
$p_id = $post->ID;
}
$args = array(
'child_of' => $p_id,
'post_type' => 'page',
'post_status' => 'publish'
);
wp_list_pages( $args );
}
Note: exemplary and untested