How can I add a class to a secondary menu?

Community Forums Forums General Discussion How can I add a class to a secondary menu?

This topic is: not resolved

Tagged: , ,

This topic contains 2 replies, has 3 voices, and was last updated by  gagn 5 months, 3 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #41513

    paulietheboss
    Participant
    Post count: 10

    Hi guys – I’m looking to add a class to a secondary navigation I have which is called sticky.
    All I’ve come across from looking online is the following code, which says it is for adding a class to primary navigation. I understand that this will not work for me, and as far as I can tell I need to incorporate genesis_do_subnav, but it’s not going to be a simple case of swapping it in. Can anyone please help?

    add_filter( 'genesis_do_nav', 'override_do_nav', 10, 3 );
    function override_do_nav($nav_output, $nav, $args) {
    
        $args['menu_id'] = 'the_id_you_want';
        $args['menu_class'] = 'class1 class2'; // replace what was there
        $args['menu_class'] .= ' class3'; // or append to it
    
        // check which function should be used to build the nav
        // rebuild the nav using the updated arguments
        if(array_key_exists('type', $args))
            $nav = wp_nav_menu( $args );
        else
            $nav = genesis_nav( $args );
    
        // return the modified result
        return sprintf( '%2$s%1$s%3$s', $nav, genesis_structural_wrap( 'nav', 'open', 0 ), genesis_structural_wrap( 'nav', 'close', 0 ) );
    
    }`
    
    
    http://www.paulietheboss.com/
    #42540

    wpspeak
    Participant
    Post count: 112

    Not sure about the code. But…. do you want to create a sticky menu? If the answer is yes, Brian had already wrote about a tutorial about this http://www.briangardner.com/sticky-menu/


    #88727

    gagn
    Member
    Post count: 4

    paulietheboss,
    Did you resolve this?
    I’m looking to do the same thing.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.