The codex is there to be used and should be your first stop. There is a complete page on conditional tags
To exclude the archive page, use is_archive()
.
EDIT 1
Mark has a valid point. I didn't understand you well, and maybe myself as well :-)
Your problem is using the ||
and &&
operators
Here is your code
if ( !is_home() || !is_page('archive') )
OK. If you are not on the home page and not on the archive page, both return true, agreed,
true || true
so your code executes as it should. Now, for instance, we are on the home page, so the check that we are not on the homepage return false, the following happens
false || true
Unlike what you think, your code should execute. This is not a flaw in your code, but how the ||
operator works. Only one true triggers and executes your code. The same happens when you are on the archive page.
The &&
operator works like this with your code
if ( !is_home() && !is_page('archive') )
If you are not on the home page and not on the archive page, both returns true and the code executes.
Now, when you are on either one of the home page or archive page, the one returns true, the other one false. Will your code still executes. The simple answer is NO
For the &&
operator to trigger, all conditions must return true. Just one false fails your code from executing.
I hope this makes sense
** EDIT 2**
From your comments
Incidentally, would !(is_home() || is_page('archive'))
be the same as !is_home() || !is_page('archive')
?
No, it is not. You need to understand what the not (!
) **operator does. !
infront of any variable or condition means the opposite of what follows afterwards. So, !is_page()
would mean in simple English, "if we are not on a page", where as is_page()
translates to "if we are on a page"
So, to look back at what I've explained in EDIT 1, lets look at the logic. I'll abbreviate is_page( 'archive' )
to just is_page()
!(is_home() || is_page('archive'))
On any other page other that home and archive page, !is_home()
returns true, and is_page()
returns false, executing your code
true || false
On the home page, !is_home
returns false, because we are on the home page. is_page()
returns false, because we are not on a page.
false || false
So your code does not execute. Now on the archive page. is_page()
will return true, while !is_home()
will return true as well
true || true
So you are still stuffed. Your code still executes on archive page.
I want to leave you with this. Don't reinvent the wheel. The logic is already there. Go and check the links provided in my answer. You should be using &&
and not ||
, no matter how you look at it, period
"not (A or B)" is the same as "(not A) and (not B)"
and"not (A and B)" is the same as "(not A) or (not B)"
. So in short: de Morgan rulez ;-)