Jump to content

Checking for multiple page ids if statement not working.


bowenac
 Share

Recommended Posts

In my footer, I'm checking if the page id equals a couple specific pages etc.

I can only get this to work if I only check for one id... Not sure why this or statement is not working.

if($page->id != 1021 || $page->id != 1105)

if($page->id != 1021|1105)

if( ($page->id != 1021) or ($page->id != 1105) )

I can't get any combination to work for some reason, but if I just check for one page id, what I'm trying to do works. But not when I check for multiple page id's...

Link to comment
Share on other sites

Your logic looks strange to me. I'd expect such a check to take a form more like one of the following;

if ($page->id == 1021 || $page->id == 1105) {
    echo "I get run if the page id is 1021 or 1105";
}

if ($page->id != 1021 && $page->id != 1105) {
    echo "I get run if page id is not 1021 and it is not 1105";
    echo "ie (In English) I get run if page id is not 1021 or 1105";
}

Does that help?

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...