• 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

Conditional 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 › Design Tips and Tricks › Conditional secondary menu

This topic is: not resolved

Tagged: Author Pro, conditional, hide, menu, secondary menu

  • This topic has 2 replies, 2 voices, and was last updated 6 years, 2 months ago by Bilsland.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • April 7, 2019 at 6:50 am #490539
    Bilsland
    Member

    I am looking to adjust the secondary menu so it only shows on a certain section and it's child pages: https://www.wordarchitect.com/books/ and then to show on only book-tag and book-series pages.

    I have been trying to implement this solution but can't get it to work, any help would be appreciated:

    Genesis Conditional Menus Revisited

    //* When a new page is selected from the primary menu,
    //* execute the change_secondary_menu function
    add_action( 'template_redirect', 'change_secondary_menu' );
    function change_secondary_menu() {
     
        //* Do nothing if menu not supported
        if ( ! genesis_nav_menu_supported( 'secondary' ) )
            return;
     
        add_filter( 'wp_nav_menu_args', 'choose_secondary_nav_menu' );
     
    }
     
    function choose_secondary_nav_menu( $args ) {
     
        if ( $args['theme_location'] == 'secondary' ) {
     
            //* default secondary menu
            $args['menu'] = 'Menu1';
     
            if( is_page() && is_subpage() == 37 ) {
                $args['menu'] = 'Menu1';
            }
     
            if( is_page() && is_subpage() == 39 ) {
                $args['menu'] = 'Menu1';
            }
     
        }
        return $args;
    }
     
    function is_subpage() {
        global $post;                              // load details about this page
     
        if ( is_page() && $post->post_parent ) {   // test to see if the page has a parent
            return $post->post_parent;             // return the ID of the parent post
     
        } else {                                   // there is no parent so ...
            return 0;                          // ... the answer to the question is false
        }
    }
    https://www.wordarchitect.com/books/
    April 7, 2019 at 11:01 am #490542
    Victor Font
    Moderator

    So my code doesn't work on your site because it's designed to work with pages. The books are not pages, they are posts. You need a different approach.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    April 7, 2019 at 1:48 pm #490545
    Bilsland
    Member

    Thanks for the heads up, I have also been targeting the wrong menu position, I needed to target genesis_before_content_sidebar_wrap

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Design Tips and Tricks’ 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

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