wp_list_pages

The timeline below displays how wordpress function wp_list_pages has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Retrieves or displays a list of pages (or hierarchical post type items) in list (li) format.
 *
 * @since 1.5.0
 * @since 4.7.0 Added the `item_spacing` argument.
 *
 * @see get_pages()
 *
 * @global WP_Query $wp_query WordPress Query object.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a list of pages. See get_pages() for additional arguments.
 *
 *     @type int          $child_of     Display only the sub-pages of a single page by ID. Default 0 (all pages).
 *     @type string       $authors      Comma-separated list of author IDs. Default empty (all authors).
 *     @type string       $date_format  PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
 *                                      Default is the value of 'date_format' option.
 *     @type int          $depth        Number of levels in the hierarchy of pages to include in the generated list.
 *                                      Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
 *                                      the given n depth). Default 0.
 *     @type bool         $echo         Whether or not to echo the list of pages. Default true.
 *     @type string       $exclude      Comma-separated list of page IDs to exclude. Default empty.
 *     @type array        $include      Comma-separated list of page IDs to include. Default empty.
 *     @type string       $link_after   Text or HTML to follow the page link label. Default null.
 *     @type string       $link_before  Text or HTML to precede the page link label. Default null.
 *     @type string       $post_type    Post type to query for. Default 'page'.
 *     @type string|array $post_status  Comma-separated list or array of post statuses to include. Default 'publish'.
 *     @type string       $show_date    Whether to display the page publish or modified date for each page. Accepts
 *                                      'modified' or any other value. An empty value hides the date. Default empty.
 *     @type string       $sort_column  Comma-separated list of column names to sort the pages by. Accepts 'post_author',
 *                                      'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
 *                                      'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
 *     @type string       $title_li     List heading. Passing a null or empty value will result in no heading, and the list
 *                                      will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
 *     @type string       $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'.
 *                                      Default 'preserve'.
 *     @type Walker       $walker       Walker instance to use for listing pages. Default empty which results in a
 *                                      Walker_Page instance being used.
 * }
 * @return void|string Void if 'echo' argument is true, HTML list of pages if 'echo' is false.
 */
function wp_list_pages($args = '')
{
    $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'item_spacing' => 'preserve', 'walker' => '');
    $parsed_args = wp_parse_args($args, $defaults);
    if (!in_array($parsed_args['item_spacing'], array('preserve', 'discard'), true)) {
        // Invalid value, fall back to default.
        $parsed_args['item_spacing'] = $defaults['item_spacing'];
    }
    $output = '';
    $current_page = 0;
    // Sanitize, mostly to keep spaces out.
    $parsed_args['exclude'] = preg_replace('/[^0-9,]/', '', $parsed_args['exclude']);
    // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array).
    $exclude_array = $parsed_args['exclude'] ? explode(',', $parsed_args['exclude']) : array();
    /**
     * Filters the array of pages to exclude from the pages list.
     *
     * @since 2.1.0
     *
     * @param string[] $exclude_array An array of page IDs to exclude.
     */
    $parsed_args['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', $exclude_array));
    $parsed_args['hierarchical'] = 0;
    // Query pages.
    $pages = get_pages($parsed_args);
    if (!empty($pages)) {
        if ($parsed_args['title_li']) {
            $output .= '<li class="pagenav">' . $parsed_args['title_li'] . '<ul>';
        }
        global $wp_query;
        if (is_page() || is_attachment() || $wp_query->is_posts_page) {
            $current_page = get_queried_object_id();
        } elseif (is_singular()) {
            $queried_object = get_queried_object();
            if (is_post_type_hierarchical($queried_object->post_type)) {
                $current_page = $queried_object->ID;
            }
        }
        $output .= walk_page_tree($pages, $parsed_args['depth'], $current_page, $parsed_args);
        if ($parsed_args['title_li']) {
            $output .= '</ul></li>';
        }
    }
    /**
     * Filters the HTML output of the pages to list.
     *
     * @since 1.5.1
     * @since 4.4.0 `$pages` added as arguments.
     *
     * @see wp_list_pages()
     *
     * @param string    $output      HTML output of the pages list.
     * @param array     $parsed_args An array of page-listing arguments. See wp_list_pages()
     *                               for information on accepted arguments.
     * @param WP_Post[] $pages       Array of the page objects.
     */
    $html = apply_filters('wp_list_pages', $output, $parsed_args, $pages);
    if ($parsed_args['echo']) {
        echo $html;
    } else {
        return $html;
    }
}

WordPress Version: 5.7

/**
 * Retrieve or display a list of pages (or hierarchical post type items) in list (li) format.
 *
 * @since 1.5.0
 * @since 4.7.0 Added the `item_spacing` argument.
 *
 * @see get_pages()
 *
 * @global WP_Query $wp_query WordPress Query object.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a list of pages. See `get_pages()` for additional arguments.
 *
 *     @type int          $child_of     Display only the sub-pages of a single page by ID. Default 0 (all pages).
 *     @type string       $authors      Comma-separated list of author IDs. Default empty (all authors).
 *     @type string       $date_format  PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
 *                                      Default is the value of 'date_format' option.
 *     @type int          $depth        Number of levels in the hierarchy of pages to include in the generated list.
 *                                      Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
 *                                      the given n depth). Default 0.
 *     @type bool         $echo         Whether or not to echo the list of pages. Default true.
 *     @type string       $exclude      Comma-separated list of page IDs to exclude. Default empty.
 *     @type array        $include      Comma-separated list of page IDs to include. Default empty.
 *     @type string       $link_after   Text or HTML to follow the page link label. Default null.
 *     @type string       $link_before  Text or HTML to precede the page link label. Default null.
 *     @type string       $post_type    Post type to query for. Default 'page'.
 *     @type string|array $post_status  Comma-separated list or array of post statuses to include. Default 'publish'.
 *     @type string       $show_date    Whether to display the page publish or modified date for each page. Accepts
 *                                      'modified' or any other value. An empty value hides the date. Default empty.
 *     @type string       $sort_column  Comma-separated list of column names to sort the pages by. Accepts 'post_author',
 *                                      'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
 *                                      'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
 *     @type string       $title_li     List heading. Passing a null or empty value will result in no heading, and the list
 *                                      will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
 *     @type string       $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'.
 *                                      Default 'preserve'.
 *     @type Walker       $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return void|string Void if 'echo' argument is true, HTML list of pages if 'echo' is false.
 */
function wp_list_pages($args = '')
{
    $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'item_spacing' => 'preserve', 'walker' => '');
    $parsed_args = wp_parse_args($args, $defaults);
    if (!in_array($parsed_args['item_spacing'], array('preserve', 'discard'), true)) {
        // Invalid value, fall back to default.
        $parsed_args['item_spacing'] = $defaults['item_spacing'];
    }
    $output = '';
    $current_page = 0;
    // Sanitize, mostly to keep spaces out.
    $parsed_args['exclude'] = preg_replace('/[^0-9,]/', '', $parsed_args['exclude']);
    // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array).
    $exclude_array = $parsed_args['exclude'] ? explode(',', $parsed_args['exclude']) : array();
    /**
     * Filters the array of pages to exclude from the pages list.
     *
     * @since 2.1.0
     *
     * @param string[] $exclude_array An array of page IDs to exclude.
     */
    $parsed_args['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', $exclude_array));
    $parsed_args['hierarchical'] = 0;
    // Query pages.
    $pages = get_pages($parsed_args);
    if (!empty($pages)) {
        if ($parsed_args['title_li']) {
            $output .= '<li class="pagenav">' . $parsed_args['title_li'] . '<ul>';
        }
        global $wp_query;
        if (is_page() || is_attachment() || $wp_query->is_posts_page) {
            $current_page = get_queried_object_id();
        } elseif (is_singular()) {
            $queried_object = get_queried_object();
            if (is_post_type_hierarchical($queried_object->post_type)) {
                $current_page = $queried_object->ID;
            }
        }
        $output .= walk_page_tree($pages, $parsed_args['depth'], $current_page, $parsed_args);
        if ($parsed_args['title_li']) {
            $output .= '</ul></li>';
        }
    }
    /**
     * Filters the HTML output of the pages to list.
     *
     * @since 1.5.1
     * @since 4.4.0 `$pages` added as arguments.
     *
     * @see wp_list_pages()
     *
     * @param string    $output      HTML output of the pages list.
     * @param array     $parsed_args An array of page-listing arguments. See wp_list_pages()
     *                               for information on accepted arguments.
     * @param WP_Post[] $pages       Array of the page objects.
     */
    $html = apply_filters('wp_list_pages', $output, $parsed_args, $pages);
    if ($parsed_args['echo']) {
        echo $html;
    } else {
        return $html;
    }
}

WordPress Version: 5.4

/**
 * Retrieve or display a list of pages (or hierarchical post type items) in list (li) format.
 *
 * @since 1.5.0
 * @since 4.7.0 Added the `item_spacing` argument.
 *
 * @see get_pages()
 *
 * @global WP_Query $wp_query WordPress Query object.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a list of pages. See `get_pages()` for additional arguments.
 *
 *     @type int          $child_of     Display only the sub-pages of a single page by ID. Default 0 (all pages).
 *     @type string       $authors      Comma-separated list of author IDs. Default empty (all authors).
 *     @type string       $date_format  PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
 *                                      Default is the value of 'date_format' option.
 *     @type int          $depth        Number of levels in the hierarchy of pages to include in the generated list.
 *                                      Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
 *                                      the given n depth). Default 0.
 *     @type bool         $echo         Whether or not to echo the list of pages. Default true.
 *     @type string       $exclude      Comma-separated list of page IDs to exclude. Default empty.
 *     @type array        $include      Comma-separated list of page IDs to include. Default empty.
 *     @type string       $link_after   Text or HTML to follow the page link label. Default null.
 *     @type string       $link_before  Text or HTML to precede the page link label. Default null.
 *     @type string       $post_type    Post type to query for. Default 'page'.
 *     @type string|array $post_status  Comma-separated list or array of post statuses to include. Default 'publish'.
 *     @type string       $show_date    Whether to display the page publish or modified date for each page. Accepts
 *                                      'modified' or any other value. An empty value hides the date. Default empty.
 *     @type string       $sort_column  Comma-separated list of column names to sort the pages by. Accepts 'post_author',
 *                                      'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
 *                                      'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
 *     @type string       $title_li     List heading. Passing a null or empty value will result in no heading, and the list
 *                                      will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
 *     @type string       $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'.
 *                                      Default 'preserve'.
 *     @type Walker       $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return void|string Void if 'echo' argument is true, HTML list of pages if 'echo' is false.
 */
function wp_list_pages($args = '')
{
    $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'item_spacing' => 'preserve', 'walker' => '');
    $parsed_args = wp_parse_args($args, $defaults);
    if (!in_array($parsed_args['item_spacing'], array('preserve', 'discard'), true)) {
        // Invalid value, fall back to default.
        $parsed_args['item_spacing'] = $defaults['item_spacing'];
    }
    $output = '';
    $current_page = 0;
    // Sanitize, mostly to keep spaces out.
    $parsed_args['exclude'] = preg_replace('/[^0-9,]/', '', $parsed_args['exclude']);
    // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array).
    $exclude_array = $parsed_args['exclude'] ? explode(',', $parsed_args['exclude']) : array();
    /**
     * Filters the array of pages to exclude from the pages list.
     *
     * @since 2.1.0
     *
     * @param string[] $exclude_array An array of page IDs to exclude.
     */
    $parsed_args['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', $exclude_array));
    $parsed_args['hierarchical'] = 0;
    // Query pages.
    $pages = get_pages($parsed_args);
    if (!empty($pages)) {
        if ($parsed_args['title_li']) {
            $output .= '<li class="pagenav">' . $parsed_args['title_li'] . '<ul>';
        }
        global $wp_query;
        if (is_page() || is_attachment() || $wp_query->is_posts_page) {
            $current_page = get_queried_object_id();
        } elseif (is_singular()) {
            $queried_object = get_queried_object();
            if (is_post_type_hierarchical($queried_object->post_type)) {
                $current_page = $queried_object->ID;
            }
        }
        $output .= walk_page_tree($pages, $parsed_args['depth'], $current_page, $parsed_args);
        if ($parsed_args['title_li']) {
            $output .= '</ul></li>';
        }
    }
    /**
     * Filters the HTML output of the pages to list.
     *
     * @since 1.5.1
     * @since 4.4.0 `$pages` added as arguments.
     *
     * @see wp_list_pages()
     *
     * @param string    $output      HTML output of the pages list.
     * @param array     $parsed_args An array of page-listing arguments.
     * @param WP_Post[] $pages       Array of the page objects.
     */
    $html = apply_filters('wp_list_pages', $output, $parsed_args, $pages);
    if ($parsed_args['echo']) {
        echo $html;
    } else {
        return $html;
    }
}

WordPress Version: 5.3

/**
 * Retrieve or display a list of pages (or hierarchical post type items) in list (li) format.
 *
 * @since 1.5.0
 * @since 4.7.0 Added the `item_spacing` argument.
 *
 * @see get_pages()
 *
 * @global WP_Query $wp_query WordPress Query object.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a list of pages. See `get_pages()` for additional arguments.
 *
 *     @type int          $child_of     Display only the sub-pages of a single page by ID. Default 0 (all pages).
 *     @type string       $authors      Comma-separated list of author IDs. Default empty (all authors).
 *     @type string       $date_format  PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
 *                                      Default is the value of 'date_format' option.
 *     @type int          $depth        Number of levels in the hierarchy of pages to include in the generated list.
 *                                      Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
 *                                      the given n depth). Default 0.
 *     @type bool         $echo         Whether or not to echo the list of pages. Default true.
 *     @type string       $exclude      Comma-separated list of page IDs to exclude. Default empty.
 *     @type array        $include      Comma-separated list of page IDs to include. Default empty.
 *     @type string       $link_after   Text or HTML to follow the page link label. Default null.
 *     @type string       $link_before  Text or HTML to precede the page link label. Default null.
 *     @type string       $post_type    Post type to query for. Default 'page'.
 *     @type string|array $post_status  Comma-separated list or array of post statuses to include. Default 'publish'.
 *     @type string       $show_date    Whether to display the page publish or modified date for each page. Accepts
 *                                      'modified' or any other value. An empty value hides the date. Default empty.
 *     @type string       $sort_column  Comma-separated list of column names to sort the pages by. Accepts 'post_author',
 *                                      'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
 *                                      'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
 *     @type string       $title_li     List heading. Passing a null or empty value will result in no heading, and the list
 *                                      will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
 *     @type string       $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'.
 *                                      Default 'preserve'.
 *     @type Walker       $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return string|void HTML list of pages.
 */
function wp_list_pages($args = '')
{
    $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'item_spacing' => 'preserve', 'walker' => '');
    $parsed_args = wp_parse_args($args, $defaults);
    if (!in_array($parsed_args['item_spacing'], array('preserve', 'discard'), true)) {
        // invalid value, fall back to default.
        $parsed_args['item_spacing'] = $defaults['item_spacing'];
    }
    $output = '';
    $current_page = 0;
    // sanitize, mostly to keep spaces out
    $parsed_args['exclude'] = preg_replace('/[^0-9,]/', '', $parsed_args['exclude']);
    // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
    $exclude_array = $parsed_args['exclude'] ? explode(',', $parsed_args['exclude']) : array();
    /**
     * Filters the array of pages to exclude from the pages list.
     *
     * @since 2.1.0
     *
     * @param array $exclude_array An array of page IDs to exclude.
     */
    $parsed_args['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', $exclude_array));
    $parsed_args['hierarchical'] = 0;
    // Query pages.
    $pages = get_pages($parsed_args);
    if (!empty($pages)) {
        if ($parsed_args['title_li']) {
            $output .= '<li class="pagenav">' . $parsed_args['title_li'] . '<ul>';
        }
        global $wp_query;
        if (is_page() || is_attachment() || $wp_query->is_posts_page) {
            $current_page = get_queried_object_id();
        } elseif (is_singular()) {
            $queried_object = get_queried_object();
            if (is_post_type_hierarchical($queried_object->post_type)) {
                $current_page = $queried_object->ID;
            }
        }
        $output .= walk_page_tree($pages, $parsed_args['depth'], $current_page, $parsed_args);
        if ($parsed_args['title_li']) {
            $output .= '</ul></li>';
        }
    }
    /**
     * Filters the HTML output of the pages to list.
     *
     * @since 1.5.1
     * @since 4.4.0 `$pages` added as arguments.
     *
     * @see wp_list_pages()
     *
     * @param string $output      HTML output of the pages list.
     * @param array  $parsed_args An array of page-listing arguments.
     * @param array  $pages       List of WP_Post objects returned by `get_pages()`
     */
    $html = apply_filters('wp_list_pages', $output, $parsed_args, $pages);
    if ($parsed_args['echo']) {
        echo $html;
    } else {
        return $html;
    }
}

WordPress Version: 5.1

/**
 * Retrieve or display a list of pages (or hierarchical post type items) in list (li) format.
 *
 * @since 1.5.0
 * @since 4.7.0 Added the `item_spacing` argument.
 *
 * @see get_pages()
 *
 * @global WP_Query $wp_query
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a list of pages. See `get_pages()` for additional arguments.
 *
 *     @type int          $child_of     Display only the sub-pages of a single page by ID. Default 0 (all pages).
 *     @type string       $authors      Comma-separated list of author IDs. Default empty (all authors).
 *     @type string       $date_format  PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
 *                                      Default is the value of 'date_format' option.
 *     @type int          $depth        Number of levels in the hierarchy of pages to include in the generated list.
 *                                      Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
 *                                      the given n depth). Default 0.
 *     @type bool         $echo         Whether or not to echo the list of pages. Default true.
 *     @type string       $exclude      Comma-separated list of page IDs to exclude. Default empty.
 *     @type array        $include      Comma-separated list of page IDs to include. Default empty.
 *     @type string       $link_after   Text or HTML to follow the page link label. Default null.
 *     @type string       $link_before  Text or HTML to precede the page link label. Default null.
 *     @type string       $post_type    Post type to query for. Default 'page'.
 *     @type string|array $post_status  Comma-separated list or array of post statuses to include. Default 'publish'.
 *     @type string       $show_date    Whether to display the page publish or modified date for each page. Accepts
 *                                      'modified' or any other value. An empty value hides the date. Default empty.
 *     @type string       $sort_column  Comma-separated list of column names to sort the pages by. Accepts 'post_author',
 *                                      'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
 *                                      'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
 *     @type string       $title_li     List heading. Passing a null or empty value will result in no heading, and the list
 *                                      will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
 *     @type string       $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'.
 *                                      Default 'preserve'.
 *     @type Walker       $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return string|void HTML list of pages.
 */
function wp_list_pages($args = '')
{
    $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'item_spacing' => 'preserve', 'walker' => '');
    $r = wp_parse_args($args, $defaults);
    if (!in_array($r['item_spacing'], array('preserve', 'discard'), true)) {
        // invalid value, fall back to default.
        $r['item_spacing'] = $defaults['item_spacing'];
    }
    $output = '';
    $current_page = 0;
    // sanitize, mostly to keep spaces out
    $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
    // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
    $exclude_array = $r['exclude'] ? explode(',', $r['exclude']) : array();
    /**
     * Filters the array of pages to exclude from the pages list.
     *
     * @since 2.1.0
     *
     * @param array $exclude_array An array of page IDs to exclude.
     */
    $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', $exclude_array));
    // Query pages.
    $r['hierarchical'] = 0;
    $pages = get_pages($r);
    if (!empty($pages)) {
        if ($r['title_li']) {
            $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
        }
        global $wp_query;
        if (is_page() || is_attachment() || $wp_query->is_posts_page) {
            $current_page = get_queried_object_id();
        } elseif (is_singular()) {
            $queried_object = get_queried_object();
            if (is_post_type_hierarchical($queried_object->post_type)) {
                $current_page = $queried_object->ID;
            }
        }
        $output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
        if ($r['title_li']) {
            $output .= '</ul></li>';
        }
    }
    /**
     * Filters the HTML output of the pages to list.
     *
     * @since 1.5.1
     * @since 4.4.0 `$pages` added as arguments.
     *
     * @see wp_list_pages()
     *
     * @param string $output HTML output of the pages list.
     * @param array  $r      An array of page-listing arguments.
     * @param array  $pages  List of WP_Post objects returned by `get_pages()`
     */
    $html = apply_filters('wp_list_pages', $output, $r, $pages);
    if ($r['echo']) {
        echo $html;
    } else {
        return $html;
    }
}

WordPress Version: 4.8

/**
 * Retrieve or display list of pages (or hierarchical post type items) in list (li) format.
 *
 * @since 1.5.0
 * @since 4.7.0 Added the `item_spacing` argument.
 *
 * @see get_pages()
 *
 * @global WP_Query $wp_query
 *
 * @param array|string $args {
 *     Array or string of arguments. Optional.
 *
 *     @type int          $child_of     Display only the sub-pages of a single page by ID. Default 0 (all pages).
 *     @type string       $authors      Comma-separated list of author IDs. Default empty (all authors).
 *     @type string       $date_format  PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
 *                                      Default is the value of 'date_format' option.
 *     @type int          $depth        Number of levels in the hierarchy of pages to include in the generated list.
 *                                      Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
 *                                      the given n depth). Default 0.
 *     @type bool         $echo         Whether or not to echo the list of pages. Default true.
 *     @type string       $exclude      Comma-separated list of page IDs to exclude. Default empty.
 *     @type array        $include      Comma-separated list of page IDs to include. Default empty.
 *     @type string       $link_after   Text or HTML to follow the page link label. Default null.
 *     @type string       $link_before  Text or HTML to precede the page link label. Default null.
 *     @type string       $post_type    Post type to query for. Default 'page'.
 *     @type string|array $post_status  Comma-separated list or array of post statuses to include. Default 'publish'.
 *     @type string       $show_date    Whether to display the page publish or modified date for each page. Accepts
 *                                      'modified' or any other value. An empty value hides the date. Default empty.
 *     @type string       $sort_column  Comma-separated list of column names to sort the pages by. Accepts 'post_author',
 *                                      'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
 *                                      'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
 *     @type string       $title_li     List heading. Passing a null or empty value will result in no heading, and the list
 *                                      will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
 *     @type string       $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'.
 *                                      Default 'preserve'.
 *     @type Walker       $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return string|void HTML list of pages.
 */
function wp_list_pages($args = '')
{
    $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'item_spacing' => 'preserve', 'walker' => '');
    $r = wp_parse_args($args, $defaults);
    if (!in_array($r['item_spacing'], array('preserve', 'discard'), true)) {
        // invalid value, fall back to default.
        $r['item_spacing'] = $defaults['item_spacing'];
    }
    $output = '';
    $current_page = 0;
    // sanitize, mostly to keep spaces out
    $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
    // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
    $exclude_array = $r['exclude'] ? explode(',', $r['exclude']) : array();
    /**
     * Filters the array of pages to exclude from the pages list.
     *
     * @since 2.1.0
     *
     * @param array $exclude_array An array of page IDs to exclude.
     */
    $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', $exclude_array));
    // Query pages.
    $r['hierarchical'] = 0;
    $pages = get_pages($r);
    if (!empty($pages)) {
        if ($r['title_li']) {
            $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
        }
        global $wp_query;
        if (is_page() || is_attachment() || $wp_query->is_posts_page) {
            $current_page = get_queried_object_id();
        } elseif (is_singular()) {
            $queried_object = get_queried_object();
            if (is_post_type_hierarchical($queried_object->post_type)) {
                $current_page = $queried_object->ID;
            }
        }
        $output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
        if ($r['title_li']) {
            $output .= '</ul></li>';
        }
    }
    /**
     * Filters the HTML output of the pages to list.
     *
     * @since 1.5.1
     * @since 4.4.0 `$pages` added as arguments.
     *
     * @see wp_list_pages()
     *
     * @param string $output HTML output of the pages list.
     * @param array  $r      An array of page-listing arguments.
     * @param array  $pages  List of WP_Post objects returned by `get_pages()`
     */
    $html = apply_filters('wp_list_pages', $output, $r, $pages);
    if ($r['echo']) {
        echo $html;
    } else {
        return $html;
    }
}

WordPress Version: 4.7

/**
 * Retrieve or display list of pages in list (li) format.
 *
 * @since 1.5.0
 * @since 4.7.0 Added the `item_spacing` argument.
 *
 * @see get_pages()
 *
 * @global WP_Query $wp_query
 *
 * @param array|string $args {
 *     Array or string of arguments. Optional.
 *
 *     @type int          $child_of     Display only the sub-pages of a single page by ID. Default 0 (all pages).
 *     @type string       $authors      Comma-separated list of author IDs. Default empty (all authors).
 *     @type string       $date_format  PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
 *                                      Default is the value of 'date_format' option.
 *     @type int          $depth        Number of levels in the hierarchy of pages to include in the generated list.
 *                                      Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
 *                                      the given n depth). Default 0.
 *     @type bool         $echo         Whether or not to echo the list of pages. Default true.
 *     @type string       $exclude      Comma-separated list of page IDs to exclude. Default empty.
 *     @type array        $include      Comma-separated list of page IDs to include. Default empty.
 *     @type string       $link_after   Text or HTML to follow the page link label. Default null.
 *     @type string       $link_before  Text or HTML to precede the page link label. Default null.
 *     @type string       $post_type    Post type to query for. Default 'page'.
 *     @type string|array $post_status  Comma-separated list or array of post statuses to include. Default 'publish'.
 *     @type string       $show_date    Whether to display the page publish or modified date for each page. Accepts
 *                                      'modified' or any other value. An empty value hides the date. Default empty.
 *     @type string       $sort_column  Comma-separated list of column names to sort the pages by. Accepts 'post_author',
 *                                      'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
 *                                      'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
 *     @type string       $title_li     List heading. Passing a null or empty value will result in no heading, and the list
 *                                      will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
 *     @type string       $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'.
 *                                      Default 'preserve'.
 *     @type Walker       $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return string|void HTML list of pages.
 */
function wp_list_pages($args = '')
{
    $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'item_spacing' => 'preserve', 'walker' => '');
    $r = wp_parse_args($args, $defaults);
    if (!in_array($r['item_spacing'], array('preserve', 'discard'), true)) {
        // invalid value, fall back to default.
        $r['item_spacing'] = $defaults['item_spacing'];
    }
    $output = '';
    $current_page = 0;
    // sanitize, mostly to keep spaces out
    $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
    // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
    $exclude_array = $r['exclude'] ? explode(',', $r['exclude']) : array();
    /**
     * Filters the array of pages to exclude from the pages list.
     *
     * @since 2.1.0
     *
     * @param array $exclude_array An array of page IDs to exclude.
     */
    $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', $exclude_array));
    // Query pages.
    $r['hierarchical'] = 0;
    $pages = get_pages($r);
    if (!empty($pages)) {
        if ($r['title_li']) {
            $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
        }
        global $wp_query;
        if (is_page() || is_attachment() || $wp_query->is_posts_page) {
            $current_page = get_queried_object_id();
        } elseif (is_singular()) {
            $queried_object = get_queried_object();
            if (is_post_type_hierarchical($queried_object->post_type)) {
                $current_page = $queried_object->ID;
            }
        }
        $output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
        if ($r['title_li']) {
            $output .= '</ul></li>';
        }
    }
    /**
     * Filters the HTML output of the pages to list.
     *
     * @since 1.5.1
     * @since 4.4.0 `$pages` added as arguments.
     *
     * @see wp_list_pages()
     *
     * @param string $output HTML output of the pages list.
     * @param array  $r      An array of page-listing arguments.
     * @param array  $pages  List of WP_Post objects returned by `get_pages()`
     */
    $html = apply_filters('wp_list_pages', $output, $r, $pages);
    if ($r['echo']) {
        echo $html;
    } else {
        return $html;
    }
}

WordPress Version: 4.6

/**
 * Retrieve or display list of pages in list (li) format.
 *
 * @since 1.5.0
 *
 * @see get_pages()
 *
 * @global WP_Query $wp_query
 *
 * @param array|string $args {
 *     Array or string of arguments. Optional.
 *
 *     @type int    $child_of     Display only the sub-pages of a single page by ID. Default 0 (all pages).
 *     @type string $authors      Comma-separated list of author IDs. Default empty (all authors).
 *     @type string $date_format  PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
 *                                Default is the value of 'date_format' option.
 *     @type int    $depth        Number of levels in the hierarchy of pages to include in the generated list.
 *                                Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
 *                                the given n depth). Default 0.
 *     @type bool   $echo         Whether or not to echo the list of pages. Default true.
 *     @type string $exclude      Comma-separated list of page IDs to exclude. Default empty.
 *     @type array  $include      Comma-separated list of page IDs to include. Default empty.
 *     @type string $link_after   Text or HTML to follow the page link label. Default null.
 *     @type string $link_before  Text or HTML to precede the page link label. Default null.
 *     @type string $post_type    Post type to query for. Default 'page'.
 *     @type string $post_status  Comma-separated list of post statuses to include. Default 'publish'.
 *     @type string $show_date	  Whether to display the page publish or modified date for each page. Accepts
 *                                'modified' or any other value. An empty value hides the date. Default empty.
 *     @type string $sort_column  Comma-separated list of column names to sort the pages by. Accepts 'post_author',
 *                                'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
 *                                'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
 *     @type string $title_li     List heading. Passing a null or empty value will result in no heading, and the list
 *                                will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
 *     @type Walker $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return string|void HTML list of pages.
 */
function wp_list_pages($args = '')
{
    $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'walker' => '');
    $r = wp_parse_args($args, $defaults);
    $output = '';
    $current_page = 0;
    // sanitize, mostly to keep spaces out
    $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
    // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
    $exclude_array = $r['exclude'] ? explode(',', $r['exclude']) : array();
    /**
     * Filters the array of pages to exclude from the pages list.
     *
     * @since 2.1.0
     *
     * @param array $exclude_array An array of page IDs to exclude.
     */
    $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', $exclude_array));
    // Query pages.
    $r['hierarchical'] = 0;
    $pages = get_pages($r);
    if (!empty($pages)) {
        if ($r['title_li']) {
            $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
        }
        global $wp_query;
        if (is_page() || is_attachment() || $wp_query->is_posts_page) {
            $current_page = get_queried_object_id();
        } elseif (is_singular()) {
            $queried_object = get_queried_object();
            if (is_post_type_hierarchical($queried_object->post_type)) {
                $current_page = $queried_object->ID;
            }
        }
        $output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
        if ($r['title_li']) {
            $output .= '</ul></li>';
        }
    }
    /**
     * Filters the HTML output of the pages to list.
     *
     * @since 1.5.1
     * @since 4.4.0 `$pages` added as arguments.
     *
     * @see wp_list_pages()
     *
     * @param string $output HTML output of the pages list.
     * @param array  $r      An array of page-listing arguments.
     * @param array  $pages  List of WP_Post objects returned by `get_pages()`
     */
    $html = apply_filters('wp_list_pages', $output, $r, $pages);
    if ($r['echo']) {
        echo $html;
    } else {
        return $html;
    }
}

WordPress Version: 4.4

/**
 * Retrieve or display list of pages in list (li) format.
 *
 * @since 1.5.0
 *
 * @see get_pages()
 *
 * @global WP_Query $wp_query
 *
 * @param array|string $args {
 *     Array or string of arguments. Optional.
 *
 *     @type int    $child_of     Display only the sub-pages of a single page by ID. Default 0 (all pages).
 *     @type string $authors      Comma-separated list of author IDs. Default empty (all authors).
 *     @type string $date_format  PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
 *                                Default is the value of 'date_format' option.
 *     @type int    $depth        Number of levels in the hierarchy of pages to include in the generated list.
 *                                Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
 *                                the given n depth). Default 0.
 *     @type bool   $echo         Whether or not to echo the list of pages. Default true.
 *     @type string $exclude      Comma-separated list of page IDs to exclude. Default empty.
 *     @type array  $include      Comma-separated list of page IDs to include. Default empty.
 *     @type string $link_after   Text or HTML to follow the page link label. Default null.
 *     @type string $link_before  Text or HTML to precede the page link label. Default null.
 *     @type string $post_type    Post type to query for. Default 'page'.
 *     @type string $post_status  Comma-separated list of post statuses to include. Default 'publish'.
 *     @type string $show_date	  Whether to display the page publish or modified date for each page. Accepts
 *                                'modified' or any other value. An empty value hides the date. Default empty.
 *     @type string $sort_column  Comma-separated list of column names to sort the pages by. Accepts 'post_author',
 *                                'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
 *                                'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
 *     @type string $title_li     List heading. Passing a null or empty value will result in no heading, and the list
 *                                will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
 *     @type Walker $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return string|void HTML list of pages.
 */
function wp_list_pages($args = '')
{
    $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'walker' => '');
    $r = wp_parse_args($args, $defaults);
    $output = '';
    $current_page = 0;
    // sanitize, mostly to keep spaces out
    $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
    // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
    $exclude_array = $r['exclude'] ? explode(',', $r['exclude']) : array();
    /**
     * Filter the array of pages to exclude from the pages list.
     *
     * @since 2.1.0
     *
     * @param array $exclude_array An array of page IDs to exclude.
     */
    $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', $exclude_array));
    // Query pages.
    $r['hierarchical'] = 0;
    $pages = get_pages($r);
    if (!empty($pages)) {
        if ($r['title_li']) {
            $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
        }
        global $wp_query;
        if (is_page() || is_attachment() || $wp_query->is_posts_page) {
            $current_page = get_queried_object_id();
        } elseif (is_singular()) {
            $queried_object = get_queried_object();
            if (is_post_type_hierarchical($queried_object->post_type)) {
                $current_page = $queried_object->ID;
            }
        }
        $output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
        if ($r['title_li']) {
            $output .= '</ul></li>';
        }
    }
    /**
     * Filter the HTML output of the pages to list.
     *
     * @since 1.5.1
     * @since 4.4.0 `$pages` added as arguments.
     *
     * @see wp_list_pages()
     *
     * @param string $output HTML output of the pages list.
     * @param array  $r      An array of page-listing arguments.
     * @param array  $pages  List of WP_Post objects returned by `get_pages()`
     */
    $html = apply_filters('wp_list_pages', $output, $r, $pages);
    if ($r['echo']) {
        echo $html;
    } else {
        return $html;
    }
}

WordPress Version: 4.3

/**
 * Retrieve or display list of pages in list (li) format.
 *
 * @since 1.5.0
 *
 * @see get_pages()
 *
 * @global WP_Query $wp_query
 *
 * @param array|string $args {
 *     Array or string of arguments. Optional.
 *
 *     @type int    $child_of     Display only the sub-pages of a single page by ID. Default 0 (all pages).
 *     @type string $authors      Comma-separated list of author IDs. Default empty (all authors).
 *     @type string $date_format  PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
 *                                Default is the value of 'date_format' option.
 *     @type int    $depth        Number of levels in the hierarchy of pages to include in the generated list.
 *                                Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
 *                                the given n depth). Default 0.
 *     @type bool   $echo         Whether or not to echo the list of pages. Default true.
 *     @type string $exclude      Comma-separated list of page IDs to exclude. Default empty.
 *     @type array  $include      Comma-separated list of page IDs to include. Default empty.
 *     @type string $link_after   Text or HTML to follow the page link label. Default null.
 *     @type string $link_before  Text or HTML to precede the page link label. Default null.
 *     @type string $post_type    Post type to query for. Default 'page'.
 *     @type string $post_status  Comma-separated list of post statuses to include. Default 'publish'.
 *     @type string $show_date	  Whether to display the page publish or modified date for each page. Accepts
 *                                'modified' or any other value. An empty value hides the date. Default empty.
 *     @type string $sort_column  Comma-separated list of column names to sort the pages by. Accepts 'post_author',
 *                                'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
 *                                'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
 *     @type string $title_li     List heading. Passing a null or empty value will result in no heading, and the list
 *                                will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
 *     @type Walker $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return string|void HTML list of pages.
 */
function wp_list_pages($args = '')
{
    $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'walker' => '');
    $r = wp_parse_args($args, $defaults);
    $output = '';
    $current_page = 0;
    // sanitize, mostly to keep spaces out
    $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
    // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
    $exclude_array = $r['exclude'] ? explode(',', $r['exclude']) : array();
    /**
     * Filter the array of pages to exclude from the pages list.
     *
     * @since 2.1.0
     *
     * @param array $exclude_array An array of page IDs to exclude.
     */
    $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', $exclude_array));
    // Query pages.
    $r['hierarchical'] = 0;
    $pages = get_pages($r);
    if (!empty($pages)) {
        if ($r['title_li']) {
            $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
        }
        global $wp_query;
        if (is_page() || is_attachment() || $wp_query->is_posts_page) {
            $current_page = get_queried_object_id();
        } elseif (is_singular()) {
            $queried_object = get_queried_object();
            if (is_post_type_hierarchical($queried_object->post_type)) {
                $current_page = $queried_object->ID;
            }
        }
        $output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
        if ($r['title_li']) {
            $output .= '</ul></li>';
        }
    }
    /**
     * Filter the HTML output of the pages to list.
     *
     * @since 1.5.1
     *
     * @see wp_list_pages()
     *
     * @param string $output HTML output of the pages list.
     * @param array  $r      An array of page-listing arguments.
     */
    $html = apply_filters('wp_list_pages', $output, $r);
    if ($r['echo']) {
        echo $html;
    } else {
        return $html;
    }
}

WordPress Version: 4.0

/**
 * Retrieve or display list of pages in list (li) format.
 *
 * @since 1.5.0
 *
 * @see get_pages()
 *
 * @param array|string $args {
 *     Array or string of arguments. Optional.
 *
 *     @type int    $child_of     Display only the sub-pages of a single page by ID. Default 0 (all pages).
 *     @type string $authors      Comma-separated list of author IDs. Default empty (all authors).
 *     @type string $date_format  PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
 *                                Default is the value of 'date_format' option.
 *     @type int    $depth        Number of levels in the hierarchy of pages to include in the generated list.
 *                                Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
 *                                the given n depth). Default 0.
 *     @type bool   $echo         Whether or not to echo the list of pages. Default true.
 *     @type string $exclude      Comma-separated list of page IDs to exclude. Default empty.
 *     @type array  $include      Comma-separated list of page IDs to include. Default empty.
 *     @type string $link_after   Text or HTML to follow the page link label. Default null.
 *     @type string $link_before  Text or HTML to precede the page link label. Default null.
 *     @type string $post_type    Post type to query for. Default 'page'.
 *     @type string $post_status  Comma-separated list of post statuses to include. Default 'publish'.
 *     @type string $show_date	  Whether to display the page publish or modified date for each page. Accepts
 *                                'modified' or any other value. An empty value hides the date. Default empty.
 *     @type string $sort_column  Comma-separated list of column names to sort the pages by. Accepts 'post_author',
 *                                'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
 *                                'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
 *     @type string $title_li     List heading. Passing a null or empty value will result in no heading, and the list
 *                                will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
 *     @type Walker $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return string HTML list of pages.
 */
function wp_list_pages($args = '')
{
    $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'walker' => '');
    $r = wp_parse_args($args, $defaults);
    $output = '';
    $current_page = 0;
    // sanitize, mostly to keep spaces out
    $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
    // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
    $exclude_array = $r['exclude'] ? explode(',', $r['exclude']) : array();
    /**
     * Filter the array of pages to exclude from the pages list.
     *
     * @since 2.1.0
     *
     * @param array $exclude_array An array of page IDs to exclude.
     */
    $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', $exclude_array));
    // Query pages.
    $r['hierarchical'] = 0;
    $pages = get_pages($r);
    if (!empty($pages)) {
        if ($r['title_li']) {
            $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
        }
        global $wp_query;
        if (is_page() || is_attachment() || $wp_query->is_posts_page) {
            $current_page = get_queried_object_id();
        } elseif (is_singular()) {
            $queried_object = get_queried_object();
            if (is_post_type_hierarchical($queried_object->post_type)) {
                $current_page = $queried_object->ID;
            }
        }
        $output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
        if ($r['title_li']) {
            $output .= '</ul></li>';
        }
    }
    /**
     * Filter the HTML output of the pages to list.
     *
     * @since 1.5.1
     *
     * @see wp_list_pages()
     *
     * @param string $output HTML output of the pages list.
     * @param array  $r      An array of page-listing arguments.
     */
    $html = apply_filters('wp_list_pages', $output, $r);
    if ($r['echo']) {
        echo $html;
    } else {
        return $html;
    }
}

WordPress Version: 3.9

/**
 * Retrieve or display list of pages in list (li) format.
 *
 * @since 1.5.0
 *
 * @param array|string $args Optional. Override default arguments.
 * @return string HTML content, if not displaying.
 */
function wp_list_pages($args = '')
{
    $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'walker' => '');
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    $output = '';
    $current_page = 0;
    // sanitize, mostly to keep spaces out
    $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
    // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
    $exclude_array = $r['exclude'] ? explode(',', $r['exclude']) : array();
    /**
     * Filter the array of pages to exclude from the pages list.
     *
     * @since 2.1.0
     *
     * @param array $exclude_array An array of page IDs to exclude.
     */
    $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', $exclude_array));
    // Query pages.
    $r['hierarchical'] = 0;
    $pages = get_pages($r);
    if (!empty($pages)) {
        if ($r['title_li']) {
            $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
        }
        global $wp_query;
        if (is_page() || is_attachment() || $wp_query->is_posts_page) {
            $current_page = get_queried_object_id();
        } elseif (is_singular()) {
            $queried_object = get_queried_object();
            if (is_post_type_hierarchical($queried_object->post_type)) {
                $current_page = $queried_object->ID;
            }
        }
        $output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
        if ($r['title_li']) {
            $output .= '</ul></li>';
        }
    }
    /**
     * Filter the HTML output of the pages to list.
     *
     * @since 1.5.1
     *
     * @see wp_list_pages()
     *
     * @param string $output HTML output of the pages list.
     * @param array  $r      An array of page-listing arguments.
     */
    $output = apply_filters('wp_list_pages', $output, $r);
    if ($r['echo']) {
        echo $output;
    } else {
        return $output;
    }
}

WordPress Version: 3.7

/**
 * Retrieve or display list of pages in list (li) format.
 *
 * @since 1.5.0
 *
 * @param array|string $args Optional. Override default arguments.
 * @return string HTML content, if not displaying.
 */
function wp_list_pages($args = '')
{
    $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'walker' => '');
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    $output = '';
    $current_page = 0;
    // sanitize, mostly to keep spaces out
    $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
    // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
    $exclude_array = $r['exclude'] ? explode(',', $r['exclude']) : array();
    $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', $exclude_array));
    // Query pages.
    $r['hierarchical'] = 0;
    $pages = get_pages($r);
    if (!empty($pages)) {
        if ($r['title_li']) {
            $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
        }
        global $wp_query;
        if (is_page() || is_attachment() || $wp_query->is_posts_page) {
            $current_page = $wp_query->get_queried_object_id();
        }
        $output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
        if ($r['title_li']) {
            $output .= '</ul></li>';
        }
    }
    $output = apply_filters('wp_list_pages', $output, $r);
    if ($r['echo']) {
        echo $output;
    } else {
        return $output;
    }
}