Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function add_menuclass_active($ulclass) {
- return preg_replace('/<a /', '<a class="list-group"', $ulclass, 1);
- }
- add_filter('wp_nav_menu', 'add_menuclass_active');
- function add_menuclass_active( $nav_menu, $args ) {
- if( $args->theme_location == 'CUSTOM MENU' )
- return preg_replace( '/<a /', '<a class="list-group"', $nav_menu, 1 );
- return $nav_menu;
- }
- add_filter( 'wp_nav_menu', 'add_menuclass_active', 10, 2 );
- register_nav_menus(array(
- 'top-menu' => __('Menu1', 'twentyfourteen'),
- 'side-menu' => __('Menu2', 'twentyfourteen'),
- 'footer-menu' => __('Menu3', 'twentyfourteen')
- ) );
- function my_walker_nav_menu_start_el($item_output, $item, $depth, $args) {
- $menu_locations = get_nav_menu_locations();
- if ( has_term($menu_locations['top-menu'], 'nav_menu', $item) ) {
- $item_output = preg_replace('/<a /', '<a class="list-group" ', $item_output, 1);
- }
- return $item_output;
- }
- add_filter('walker_nav_menu_start_el', 'my_walker_nav_menu_start_el', 10, 4);
- function my_walker_nav_menu_start_el($item_output, $item, $depth, $args) {
- $menu_locations = get_nav_menu_locations();
- if ( has_term($menu_locations['top-menu'], 'nav_menu', $item) ) {
- $item_output = preg_replace('/<a /', '<a class="list-group" ', $item_output, 1);
- if ($item->menu_order == 1){
- $item_output = preg_replace('/<a /', '<a class="list-group active" ', $item_output, 1);
- }
- }
- return $item_output;
- }
- add_filter('walker_nav_menu_start_el', 'my_walker_nav_menu_start_el', 10, 4);
- function my_walker_nav_menu_start_el($item_output, $item, $depth, $args) {
- $menu_locations = get_nav_menu_locations();
- if ( has_term($menu_locations['top-menu'], 'nav_menu', $item) ) {
- $item_output = preg_replace('/<a /', '<a class="list-group" ', $item_output, 1);
- }
- if ($item->menu_order == 1){
- $item_output = preg_replace('/<a /', '<a class="active" ', $item_output, 1);
- }
- return $item_output;
- }
- add_filter('walker_nav_menu_start_el', 'my_walker_nav_menu_start_el', 10, 4);
Add Comment
Please, Sign In to add comment