wp-includes/post-template.php:1293Retrieves or displays a list of pages (or hierarchical post type items) in list (li) format.
$argsarray|stringoptional''$child_ofintdefault: 0 (all pages)
$authorsstringdefault: empty (all authors)
$date_formatstringdefault: is the value of 'date_format' option
$depthintdefault: 0
$echobooldefault: true
$excludestringdefault: empty
$includearraydefault: empty
$link_afterstringdefault: null
$link_beforestringdefault: null
$post_typestringdefault: 'page'
$post_statusstring|arraydefault: 'publish'
$show_datestringdefault: empty
$sort_columnstringdefault: 'post_title'
$title_listringdefault: 'Pages'
$item_spacingstringdefault: 'preserve'
$walkerWalkerdefault: empty which results in a Walker_Page instance being used
void|string2 hooks fire while wp_list_pages() runs, in this order:
Filters the array of pages to exclude from the pages list.
Filters the HTML output of the pages to list.
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.Introduced in 1.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/post-template.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.