Conditionally Remove Nav Menu on Pages

Community Forums Forums General Discussion Conditionally Remove Nav Menu on Pages

This topic is: not resolved

This topic contains 4 replies, has 3 voices, and was last updated by  Gary Jones 1 year, 10 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #85771

    Justin Romack

    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?


    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

    David Chu

    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


    Justin Romack

    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!


    David Chu

    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


    Gary Jones

    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.

    Changes in Genesis 2.1 – the ultimate guide to every single change in Genesis Framework 2.1, 2.1.1 and 2.1.2 (all 90 of them!) | @GaryJ

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

You must be logged in to reply to this topic.