On this page
walk_page_tree( array $pages, int $depth, int $current_page, array $args ): string
Retrieves HTML list content for page list.
Parameters
$pagesarray Required$depthint Required$current_pageint Required$argsarray Required
Return
string
Source
File: wp-includes/post-template.php. View all references
function walk_page_tree( $pages, $depth, $current_page, $args ) {
if ( empty( $args['walker'] ) ) {
$walker = new Walker_Page;
} else {
/**
* @var Walker $walker
*/
$walker = $args['walker'];
}
foreach ( (array) $pages as $page ) {
if ( $page->post_parent ) {
$args['pages_with_children'][ $page->post_parent ] = true;
}
}
return $walker->walk( $pages, $depth, $args, $current_page );
}
Related
Uses
| Uses | Description |
|---|---|
| Walker::walk() wp-includes/class-wp-walker.php | Displays array of elements hierarchically. |
Used By
| Used By | Description |
|---|---|
| wp_list_pages() wp-includes/post-template.php | Retrieves or displays a list of pages (or hierarchical post type items) in list (li) format. |
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/walk_page_tree