Advertisement
firoze

description menu debuging config true

Apr 3rd, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. // call this in template where menu will display
  2. <?php $walker = new description_walker; ?>
  3. <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu', 'walker' => $walker ) ); ?>
  4.  
  5.  
  6. // call this into your functions.php
  7.  
  8. // menu description
  9.  
  10.  
  11. class description_walker extends Walker_Nav_Menu
  12. {
  13. function start_el(&$output, $item, $depth = 0, $args = array(), $current_object_id = 0)
  14. {
  15. global $wp_query;
  16. $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
  17.  
  18. $class_names = $value = '';
  19.  
  20. $classes = empty( $item->classes ) ? array() : (array) $item->classes;
  21.  
  22. $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
  23. $class_names = ' class="'. esc_attr( $class_names ) . '"';
  24.  
  25. $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
  26.  
  27. $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
  28. $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
  29. $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
  30. $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
  31.  
  32. $prepend = '<strong>';
  33. $append = '</strong>';
  34. $description = ! empty( $item->description ) ? '</br><span>'.esc_attr( $item->description ).'</span>' : '';
  35.  
  36. if($depth != 0)
  37. {
  38. $description = $append = $prepend = "";
  39. }
  40.  
  41. $item_output = $args->before;
  42. $item_output .= '<a'. $attributes .'>';
  43. $item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append;
  44. $item_output .= $description.$args->link_after;
  45. $item_output .= '</a>';
  46. $item_output .= $args->after;
  47.  
  48. $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args, $current_object_id );
  49. }
  50. }
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. // source link:
  58.  
  59. http://www.kriesi.at/archives/improve-your-wordpress-navigation-menu-output
  60.  
  61.  
  62. // problem solution:by the person name is Ignacio Atencia
  63. https://wordpress.org/support/topic/strict-standards-declaration-of-should-be-compatible-with
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement