twentyfifteen_nav_description

Display descriptions in main navigation.

Description

(string) twentyfifteen_nav_description( (string) $item_output, (WP_Post) $item, (int) $depth, (array) $args ); 

Returns (string)

Menu item with possible description.

Parameters (4)

0. $item_output (string)
The menu item output.
1. $item (WP_Post)
Menu item object.
2. $depth (int)
Depth of the menu.
3. $args (array)
wp_nav_menu() arguments.

Usage

  1. if ( !function_exists( 'twentyfifteen_nav_description' ) ) { 
  2. require_once '/functions.php'; 
  3.  
  4. // The menu item output. 
  5. $item_output = ''; 
  6.  
  7. // Menu item object. 
  8. $item = null; 
  9.  
  10. // Depth of the menu. 
  11. $depth = -1; 
  12.  
  13. // wp_nav_menu() arguments. 
  14. $args = array(); 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = twentyfifteen_nav_description($item_output, $item, $depth, $args); 
  18.  

Defined (1)

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

/functions.php  
  1. function twentyfifteen_nav_description( $item_output, $item, $depth, $args ) { 
  2. if ( 'primary' == $args->theme_location && $item->description ) { 
  3. $item_output = str_replace( $args->link_after . '</a>', '<div class="menu-item-description">' . $item->description . '</div>' . $args->link_after . '</a>', $item_output ); 
  4.  
  5. return $item_output;