• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

How can I add a class to a secondary menu?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

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

This topic is: not resolved

Tagged: class, nav, subnav

  • This topic has 2 replies, 3 voices, and was last updated 12 years ago by gagn.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • May 18, 2013 at 10:28 am #41513
    paulietheboss
    Member

    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/
    May 24, 2013 at 7:05 pm #42540
    wpspeak
    Member

    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/


    WP Speak | Help the Awesome #Genesiswp Community

    February 5, 2014 at 3:10 am #88727
    gagn
    Member

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

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble