WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My objective - Display some code on every page apart from 2 pages.

Now this code works fine with only one page (if its not is_home, display code)...

<?php if (!is_home()) { ?>  
(some content)
<?php ?>

... but when I try to do it for two pages, the rule fails, and the code is displayed on both the pages where I do not want it visible...

<?php if( !is_home() or !is_archive()) { ?> 
(some content)
<?php ?>

I am unsure why this fails, any help would be great.

Thanks in advance.

share|improve this question
use if ((!is_home()) || (!is_archive())) – Kuldeep Daftary Dec 9 '12 at 0:38
thanks but that doesn't work either. – Adam Dec 9 '12 at 0:46
up vote 1 down vote accepted

If you're testing against two falses you have to use the logical AND operator, because BOTH have the be false.

<?php if( !is_home() && !is_archive()) { ?> 
(some content)
<?php ?>
share|improve this answer
Yes! I knew it was something like that but couldn't put my finger on it. Thanks! – Adam Dec 9 '12 at 13:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.