Advertisement
Guest User

Untitled

a guest
Oct 6th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. register_nav_menus( array(
  2.     'primary' => 'Videos',
  3.     'secondary' => 'Site'
  4. ) );
  5.  
  6. function my_walker_nav_menu_start_el($item_output, $item, $depth, $args) {
  7.     $menu_locations = get_nav_menu_locations();
  8.  
  9.     if ( has_term($menu_locations['primary'], 'nav_menu', $item) ) {
  10.        $item_output = preg_replace('/<a /', '<a class="list-group-item" ', $item_output, 1);
  11.     }
  12.  
  13.     return $item_output;
  14. }
  15. add_filter('walker_nav_menu_start_el', 'my_walker_nav_menu_start_el', 10, 4);
  16.  
  17. // In template
  18.  
  19.                         <?php
  20.                             $menuParameters = array(
  21.                                         'menu'  => 'Videos',
  22.                               'container'       => false,
  23.                               'echo'            => false,
  24.                               'items_wrap'      => '%3$s',
  25.                               'depth'           => 0
  26.                             );
  27.  
  28.                             echo strip_tags(wp_nav_menu( $menuParameters ), '<a>' );
  29.                         ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement