Вывод подстраниц в виде списка

function wpb_list_child_pages( $atts = array() ) {
    
	if(!is_user_logged_in()) return '';
	$atts = shortcode_atts( array(
        'id'   => 0,
        'slug' => '',
    ), $atts );

    if ( $atts['slug'] ) {
        global $wpdb;

        $q = $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = %s", $atts['slug'] );
        $post_id = $wpdb->get_var( $q );

        if ( ! $post_id ) {
            return '';
        }
    } else {
        $post_id = absint( $atts['id'] );
    }
	$childpages = '';
	
    $post = get_post( $post_id ); // WP_Post on success.c
		
    if ( $post && is_post_type_hierarchical( $post->post_type ) ) {
		$childpages = wp_list_pages( array(
			'authors' => '',
			'child_of' => $post->ID,
			'post_status' => 'publish',
			'title_li' => '',
			'depth'        => 2,
			'echo'     => 0,
		) );
    }

    if ( $childpages ) {
        $childpages = '<ul>' . $childpages . '</ul>';
    }
	//if(count($pages_array_roles) < 1) array_push($pages_array_roles, 0);
	//$childpages = $childpages.'                 <br /> post='.implode(" | " , $pages_array_roles).' <br/> user='.implode(" | " , $user_uam_groups_id);
    return $childpages;
}
add_shortcode( 'wpb_childpages', 'wpb_list_child_pages' );