• 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

Conditionally Do Specific Menu in Secondary Location

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 › Conditionally Do Specific Menu in Secondary Location

This topic is: not resolved

Tagged: Genesis Simple Menus, menus, navigation

  • This topic has 4 replies, 2 voices, and was last updated 8 years, 9 months ago by pressaholic.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • May 2, 2014 at 10:18 pm #103398
    pressaholic
    Member

    Hi everyone,

    I am using the Genesis Simple Menus to display my secondary menu on certain pages but I need to expand my requirements a bit beyond the plugin. I would like to do a certain menu in the secondary location based on different conditionals but I haven't found anything to add to the code to execute the specific menu. For example, I want to display a menu called My Menu on posts with a category ID of 7. My code would be something like:

    
    add_action('genesis_after_header','conditional_my_nav');
    /**
     * If the current post is in category ID 7 then do My Menu in secondary navigation
     */
    function conditional_my_nav() {
        if (in_category(7)) { 
    		add_action( 'genesis_after_header', 'do_conditional_my_nav' );
    		function do_conditional_my_nav() {
    			wp_nav_menu( array('theme_location' => 'Secondary Navigation Menu',  'menu' => 'My Menu'));
    		}
        }  
    }
    

    I know I'm missing something but I can't see it. Any help or links would be most appreciated!

    May 2, 2014 at 10:40 pm #103402
    Tom
    Participant

    Genesis Simple Menus will serve up secondary menus based on post category or tag setting.

    From your dashboard, navigate to Posts > Categories. Edit your selected category, navigating to "Secondary Navigation". From the drop-down selector choose the secondary menu you want to appear for that category.


    Choose your next site design from over 350 Genesis themes.
    [ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]

    May 2, 2014 at 10:47 pm #103404
    pressaholic
    Member

    Well would you look at that! Amazing! Thanks for making me feel like a fool for wasting hours trying to code a solution that was already there. =) Can the Simple Menus plugin also apply the menu to child pages if the parent page has the menu applied? Thanks for your help, Tom.

    May 2, 2014 at 11:16 pm #103410
    Tom
    Participant

    Pages each require a specific selection of secondary menu, whether parent or child.

    This is entirely workable if you don't have 10^6 pages, which would be a Bad Thing anyway 🙂 .


    Choose your next site design from over 350 Genesis themes.
    [ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]

    May 2, 2014 at 11:31 pm #103413
    pressaholic
    Member

    Right! Well thanks so much for taking the time to answer my questions. 🙂

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 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

© 2023 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