If is not Singular of a specific Post Type


I’m looking to exclude elements of a L&L template when a Singular Post of a project CPT is displayed.

I tried different things without any success:

<If singular="project" is_not>
<If singular="post" is_not type="project">
<If singular="post" is_not="project">
<If route is_not="project/*">

Can you please help?

I haven’t used that condition myself very much, but I just tried it out. I noticed that when I use the comparison not instead of is_not, it seems to work as I’d expect for some reason. So this works for me: <If singular="post" not type="project">. I think I’ll send this one up the ladder to get some clarification about whether I/we are using it wrong or if there’s simply a bug where that condition isn’t accepting the normal comparisons of the If tag. I’ll keep you posted.

Hi @benjamin,

It works with not instead of is_not indeed.
So close, thank you for testing and confirming! :grinning:

Hey @avanti, I finally had a dev look into this a little and discovered something interesting about why not works but is_not doesn’t, despite the fact that is_not is what’s documented as a comparison for the If tag. Here’s what I heard from a dev:

I looked at the code on how the singular condition is being checked. I believe it’s intended that is_not does not work with singular. In fact, I believe all the comparisons do not work with singular because when I check the logic rules, singular does not contain any operands. However, a not check is separate from this. not can always be used to negate the calculated value of each condition. So whatever the value calculated is, true or false, if there’s a not, it will become false or true respectively.

I thought that was pretty interesting. So I think <If not singular type="project"> or <If singular not type="project"> are fine ways to write this in this case and isn’t a bug, it’s just making use of a “secret” not attribute that makes true logic false and false logic true. If you wanted to strictly stick to documented stuff, I suppose the other option would be to do <If singular type="project"><Else />... but that seems a little more awkward.

I’ve asked if it would be possible to make If singular for with the is and is_not comparisons so we’ll see if we can make that a bit more intuitive/consistent in the future. But I figured you might want to know that using the not attribute is fine in this case and understand why that’s the case.


Hi @benjamin,

Thanks for all the valuable details.
I retain that not is the master key in this case.