drinkingsouls
Member
Posted 1 year ago #
Hey guys,
I'm using conditional statements in my theme. I'm trying to check if it is not a home page or a single post.
if (!is_home()) Works great to say if it is not the home page.
I tried if (!is_home() || !is_single()) but I can't get that to work. I need to say if it is not the home page or a single post.
Any ideas?
Any help is appreciated.
Thanks
You want to use:
if ( !is_home() && !is_single() )
the "!" part means "not".
so try this:
if (!is_home() || is_single())
This means: if it's not the home page or if it's a single post.
xGEcoder
Member
Posted 1 year ago #
Memories of my college logic course!
Are you testing that it is not a home page and it is not a single post?
The coding becomes clearer when you first word it that way.
Being a newcomer to WP, templates, html and PHP I don't know those coding conventions but that's how I approached that logic in earlier languages.
drinkingsouls
Member
Posted 1 year ago #
Thanks a ton Curtiss Grymala, that was it.
Just to clear it up, yes I'm testing that it is not the home page and not a single post. The code that worked it:
if ( !is_home() && !is_single() )