• 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 Remove Nav Menu on Pages

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 Remove Nav Menu on Pages

This topic is: not resolved

Tagged: generate, navigation, php

  • This topic has 4 replies, 3 voices, and was last updated 9 years, 2 months ago by Gary Jones.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • January 18, 2014 at 2:48 pm #85771
    Justin Romack
    Participant

    Hi there,

    I'm building a site locally using the Generate theme as a base, and I'm hitting a snag with something I'm trying to do.

    I'm launching the site in April, but offering an opt-in and free download until then. I know folks will try to poke around (plus, I'm developing content behind the scenes), so I'm trying to remove the navigation menu from a few pages.

    I get a blank screen any time I use this code. What am I doing wrong here?

    <?php

    if(is_page(array(2,13,15,17,19,21,23) {)
    remove_action('genesis_after_header', 'genesis_do_nav');
    }

    ?>

    Any help would be appreciated. Thanks! 🙂

    ~ Justin

    http://Local build
    January 18, 2014 at 3:19 pm #85773
    David Chu
    Participant

    Hi,
    Try this. I just did adjustments at the end of the line with the array. I didn't test it, though.

    if(is_page(array(2,13,15,17,19,21,23) ) ) {
    remove_action(‘genesis_after_header’, ‘genesis_do_nav’);
    }
    
    

    Cheers, Dave


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

    January 18, 2014 at 3:42 pm #85779
    Justin Romack
    Participant

    Okay, so I'm a dork. (And being totally blind is actually a semi-valid excuse here).

    Didn't notice I had accidentally put a parenthesis at the end of that line...though I hadn't in other attempts.

    So, I cleaned up the code (with your suggestions), and I don't get a blank screen—but I also don't get the result I'm wanting.

    Am I missing something? This should remove the primary navigation menu on the pages specified in the array, correct?

    Thanks again!

    January 19, 2014 at 1:38 pm #85939
    David Chu
    Participant

    The syntax now seems OK. And that function will take an array. It generally should work fine.

    It could be the context - that won't work if you stick it in the loop, for instance, such as in a template file. Or if that code comes before executed code that deals with menus, then it could be nullified. That's the best I can offer.

    Good luck, D


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

    January 19, 2014 at 4:56 pm #85989
    Gary Jones
    Member

    Wrap the code in a function, and hook that function in to the genesis_before action hook. If you've got it just in the child theme plugin files, then you might be removing before Genesis has had a chance to add it in the first place.


    WordPress Engineer, and key contributor the Genesis Framework | @GaryJ

  • 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