walk_page_dropdown_tree() WordPress Function

The walk_page_dropdown_tree() function walks through the pages in a WordPress site and outputs a dropdown menu of those pages. The function takes two arguments: the first is the depth of the pages to include in the menu (e.g. 0 for all pages, 1 for top-level pages only, 2 for top-level and second-level pages, etc.), and the second is an array of arguments to control the output of the menu. The walk_page_dropdown_tree() function is a great way to create a hierarchical navigation menu for a WordPress site. By default, the function will output a menu with all pages in the site, but the depth argument can be used to limit the menu to only top-level pages, or to a specific depth. The function also accepts an array of arguments to control the output of the menu, including the 'id', 'class', and 'selected' attributes.

walk_page_dropdown_tree( mixed $args ) #

Retrieves HTML dropdown (select) content for page list.


Description

Top ↑

See also


Top ↑

Parameters

$args

(mixed)(Required)Elements array, maximum hierarchical depth and optional additional arguments.


Top ↑

Return

(string)


Top ↑

Source

File: wp-includes/post-template.php

function walk_page_dropdown_tree( ...$args ) {
	if ( empty( $args[2]['walker'] ) ) { // The user's options are the third parameter.
		$walker = new Walker_PageDropdown;
	} else {
		/**
		 * @var Walker $walker
		 */
		$walker = $args[2]['walker'];
	}

	return $walker->walk( ...$args );
}


Top ↑

Changelog

Changelog
VersionDescription
5.3.0Formalized the existing ...$args parameter by adding it to the function signature.
2.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.