1

crafting a theme from finished html/css markup and wonder how to wrap a tags in my custom class? With ul wrapper this is works:

            wp_nav_menu(
                array('menu' => 'menu-header',
                      'menu_class' => 'list',)
            );

but how to deal with menu items, and with currently selected menu item? I need ul to be with .class selector and li with .item selector as well

2 Answers 2

0

The following example adds a unique CSS class to a single, specific nav menu item.

function my_special_nav_class( $classes, $item ) {

    if ( is_single() && $item->title == 'Blog' ) {
        $classes[] = 'special-class';
    }

    return $classes;

}

add_filter( 'nav_menu_css_class', 'my_special_nav_class', 10, 2 );
0

ok this is too trivial, all i was need it a filter on nav_menu_css_class

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.