Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. /**
  2. * ==============================================================================
  3. * INSERT CLASSES IN TO NAV ITEMS
  4. * ==============================================================================
  5. */
  6.  
  7. /**
  8. * Store class names in menu description field.
  9. * Used, eg. to make a nav item hidden
  10. */
  11.  
  12. /**
  13. * Descriptions on Header Menu
  14. * @author Bill Erickson
  15. * @link http://www.billerickson.net/code/add-description-to-wordpress-menu-items/
  16. *
  17. * @param string $item_output, HTML outputp for the menu item
  18. * @param object $item, menu item object
  19. * @param int $depth, depth in menu structure
  20. * @param object $args, arguments passed to wp_nav_menu()
  21. * @return string $item_output
  22. */
  23.  
  24. // Use menu item description field to store class name for output to link
  25. function be_header_menu_desc( $item_output, $item, $depth, $args ) {
  26.  
  27. // Only if menu is footermenu1
  28. if( 'footermenu1' == $args->theme_location && ! $depth && $item->description )
  29. $item_output = str_replace( '<a ', '<a ' . $item->description .' ', $item_output );
  30.  
  31. return $item_output;
  32. }
  33. add_filter( 'walker_nav_menu_start_el', 'be_header_menu_desc', 10, 4 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement