• Hey Guys,

    I am trying to make it so that the sidebar does not show up on specific pages. My code

    <?php if(!is_page(‘new-moon’)) {
    get_sidebar();
    }
    ?>

    makes it so that it doesn’t pull the sidebar on the page new-moon. I want it so that it doesn’t pull the sidebar on more than just new moon. So for example, both new-moon and old-moon. Does any PHP expert know the code for this?

    Thank you very much in advance,

    D

Viewing 4 replies - 1 through 4 (of 4 total)
  • You could use the OR operator..

    <?php if( !is_page('new-moon') || !is_page(old-moon') ) {
    get_sidebar();
    }
    ?>

    Don’t know if WP has a shortened version where you could use an amperstand within the is_page possibly…

    EDIT: Yes you can, here is a more simplfiied version:

    <?php if( !is_page('new-moon','old-moon')  ) {
    get_sidebar();
    }
    ?>

    Just seperate them via commas. More info here

    Thread Starter udt123

    (@udt123)

    Thanks for your help xdesi!

    I tried both codes but it does not work for some reason. Do you think it might have something to do with my theme? the not equal to function works very well with only 1 page, but I have been trying for hours to get it work for 2 with no avail.Thank you for your time.

    D

    Sorry on further inspection it should be:

    <?php if( !is_page(array('new-moon','old-moon'))  ) {
    get_sidebar();
    }
    ?>
    Thread Starter udt123

    (@udt123)

    Thx for all your help and your time xdesi. It worked perfectly =)

    D

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHP NOT equal to help’ is closed to new replies.