I have a page (titled PPC) and a custom post type (titled Presentations) that I don't want certain elements to appear on. I thought this code would work :
<?php
if ((!is_page('PPC')) || (!is_singular('presentations'))) {
?>
<section id="menu" >
<div >
<nav role="navigation" >
<?php
$nav_classes = 'header__menu header__menu--global';
include(locate_template('components/component-nav.php', false, false));
?>
</nav>
</div>
</section>
<div >
<button id="toggleHeaderHamburger" onclick="toggleHeaderView()" >
<span ></span>
</button>
</div>
<?php } ?>
Using each conditional by itself, without the ||, works fine. But when I combine them both and use the logical operator, nothing works. I've also tried taking the wrapping parentheses out as well, so it looks like this:
if (!is_page('PPC')) || (!is_singular('presentations')) {
But then I get an error. What am I doing wrong here?
CodePudding user response:
As you've written it, !is_page('PPC') || !is_singular('presentations')
would roughly translate it as "one of neither of these" which is a logical absurbity. Within the evaulation of that expression, if it's "not a PPC" it no longer matters whether or not it is "a presentation", and vice-versa.
What you want is "either of these" is_page('PPC') || is_singular('presentations')
prefixed with a "not" for:
! ( is_page('PPC') || is_singular('presentations') )
"Not either of these".