Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. <?php wp_nav_menu( array( 'menu' => 'Primary Navigation', 'container' => '', 'walker' => new rc_scm_walker) ); ?>
  2. <?php //remove this
  3. class rc_scm_walker extends Walker_Nav_Menu
  4. {
  5. function start_el(&$output, $item, $depth, $args)
  6. {
  7. global $wp_query;
  8. $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
  9.  
  10. $class_names = $value = '';
  11.  
  12. $classes = empty( $item->classes ) ? array() : (array) $item->classes;
  13.  
  14. $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
  15. $class_names = ' class="'. esc_attr( $class_names ) . '"';
  16.  
  17. $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
  18.  
  19. $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
  20. $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
  21. $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
  22. $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
  23.  
  24. $thumbnail = '';
  25. if ( has_post_thumbnail( $item->object_id )) {
  26. $thumbnail = get_the_post_thumbnail_url( $item->object_id, 'medium' );
  27. }
  28.  
  29. $prepend = '<strong>';
  30. $append = '</strong>';
  31. $description = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : '';
  32.  
  33. if($depth != 0)
  34. {
  35. $description = $append = $prepend = "";
  36. }
  37.  
  38. if($item->description) {
  39. $customdescription = '<p>' . $item->description . '</p>';
  40. $customImage = '<div style="background-image:url(' . $thumbnail . ')"></div>';
  41. $titleWrap = '<span class="title">';
  42. $titleWrapClose = '</span>';
  43. } else {
  44. $customdescription = '';
  45. $customImage = '';
  46. $titleWrap = '';
  47. $titleWrapClose = '';
  48. }
  49.  
  50.  
  51. $item_output = $args->before;
  52. $item_output .= '<a'. $attributes .'>' . $titleWrap;
  53. $item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append;
  54. $item_output .= $description.$args->link_after;
  55. $item_output .= $titleWrapClose . $customImage . $customdescription . '</a>';
  56. $item_output .= $args->after;
  57.  
  58. $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement