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 3 months ago.

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

    Justin Romack
    Participant
    Post count: 4

    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
    #85773

    David Chu
    Participant
    Post count: 1184

    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


    David Chu · Custom WordPress Developer – likes collaborating with Designers

    #85779

    Justin Romack
    Participant
    Post count: 4

    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!

    #85939

    David Chu
    Participant
    Post count: 1184

    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


    David Chu · Custom WordPress Developer – likes collaborating with Designers

    #85989

    Gary Jones
    Moderator
    Post count: 622

    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.0 – the ultimate guide to every single change in Genesis Framework 2.0, 2.0.1 and 2.0.2 (all 159 of them!) | @GaryJ

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

You must be logged in to reply to this topic.