php如果+或声明[关闭]

I've been trying the following:

 <?php if ((!is_page(9)) || (!is_page(52))) : ?>
 <?php if (!is_page(9) || !is_page(52)) : ?>

But the moment I add the || the if stops working and only the else displays

I want to accomplish this: do this on page 9 or page 52

What is the error here?

Your condition:

(!is_page(9) || !is_page(52))

Translates to this:

!(is_page(9) && is_page(52))

This can of course never be true, a page can't be two things at the same time :)

I want to accomplish this: do this on page 9 or page 52

Just remove the negation and you should be fine:

if (is_page(9) || is_page(52)) {
    // do something
} else { 
    // this was not 9 nor 52
}
if(is_page(9) || is_page(52)) { /* Do this */ }
else { /* Do other stuff */ }

|| - OR

&& - AND

It looks like you have interrupted the parentheses for the if statement. Is is_page a function? Try:

<?php if(!is_page(9) || !is_page(52)) : ?>