walk_nav_menu_tree

Retrieve the HTML list content for nav menu items.

Description

(string) walk_nav_menu_tree( (array) $items, (int) $depth, (stdClass) $r ); 

Returns (string)

The HTML list content for the menu items.

Parameters (3)

0. $items (array)
The menu items, sorted by each menu item's menu order.
1. $depth (int)
Depth of the item in reference to parents.
2. $r (stdClass)
An object containing wp_nav_menu() arguments.

Usage

  1. if ( !function_exists( 'walk_nav_menu_tree' ) ) { 
  2. require_once ABSPATH . WPINC . '/nav-menu-template.php'; 
  3.  
  4. // The menu items, sorted by each menu item's menu order. 
  5. $items = array(); 
  6.  
  7. // Depth of the item in reference to parents. 
  8. $depth = -1; 
  9.  
  10. // An object containing wp_nav_menu() arguments. 
  11. $r = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = walk_nav_menu_tree($items, $depth, $r); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/nav-menu-template.php  
  1. function walk_nav_menu_tree( $items, $depth, $r ) { 
  2. $walker = ( empty($r->walker) ) ? new Walker_Nav_Menu : $r->walker; 
  3. $args = array( $items, $depth, $r ); 
  4.  
  5. return call_user_func_array( array( $walker, 'walk' ), $args );