Browser: Chrome 110 OS: macOS / Windows / Linux / etc. URL: Link to a page that illustrates this issue Video: Short screen recording that illustrates this issue (free tool: jam.dev)
[Please describe this bug in as much detail as possible so we can replicate & debug this bug]
When using page conditions to show/hide templates/sections in pages based on conditions, AND is having to be used to get a variety of conditions to work - when it should be OR?
I think this has been reported before and been said to be fixed, but for me, I still have to keep using AND in order to get conditions that are each separate (OR) to work.
i.e Querying a post type, page ID, or ACF like in this screenshot:
These things are all separate conditions and not ones that need to all be true/false. It also makes it really hard to then create groups of AND conditions mixed in (i.e If post type is Events and not and archive page).
I know where the OR option is, my post is about the fact it doesn’t work? If the options are set to OR, they don’t work. I am having to still use AND instead of OR for conditions to work.
It does oddly work for some instances, but the example I shared was in the header section of the website - so not sure if that’s related.
Sorry André you’re absolutely right, I was referring to element conditions in this instance. I’m not sure if PC do the same thing, so I’ll update my post to correct phrasing.
That’s correct! For instance if I change the last condition there to say OR, i.e If it is JUST of the post type Events, the element will show again on pages with that post type.
As soon as I change it to AND, it works.
It’s also the same for the Post ID rule, where Post/Page ID 2 will still show this element unless I set it to AND.
I can give you logins if it helps, I’ve just tried it again to hide a template (I am using templates mostly pulled into pages, with conditions on those) and if I set it to AND, it’s hidden, but OR, and it shows:
it’s possible you’re misunderstanding the conditions. (difficult to tell as we don’t know what that echo function and dynamic tag are returning) we’d need a simplified example without custom functions.
However, in your video, that header part will be showing because the first lot of conditions is returning TRUE. Everything up to the OR.
And the second part, ‘OR the post isn’t post 902’ becomes irrelevant, because the first part was TRUE. And adding the OR means it doesn’t need the second part to be true, only for one of them to be true. So whatever you add in the next bit won’t matter if the first part is already true.
You might be right there dude, but the conditions definitely don’t all apply or removing the last rule would mean the third rule of isn’t post ID would not show before I add it, right? But it does
Did you see my video dude? Basically all those conditions I wanted isolated, they don’t need to group up.
I had the same issue in reverse, as I mentioned above, where I did want things to be AND - but they were treated like OR as I found in my first video.
Either I’m drastically misunderstanding the use case here or we’re talking at cross purposes and my install for whatever reason is not behaving as expected. Thing is, it’s been the same on other fresh installs I’ve had too
They can only be set up be ALL true (meaning you use AND between each one), or they can be set up so ANY can be true (meaning you use OR between them).
We can’t see from your video which is true or false, as you’re using custom functions. So we don’t know which are returning true and which aren’t for that post (apart from the post IDs one).
If you can give that info or simplify the example so it doesn’t include those unknowns, it’ll be easily solved.
My guess is that AND is actually correct for what you’re trying to do, because the conditions are negatives (is empty, isn’t post ID, isn’t Events) and so using OR would be incorrect and would just show the element the moment that one of them is true (which would be pretty much every page).
Yes you’re 100% on the mark with your last statement. By isolated I mean, on their own (OR) and not grouped (AND). The echo was for an ACF field tick box in the backend, if it’s ticked, hide it (again as an OR, I don’t want these conditions combined as AND).
You can see towards the end of the video, I set an OR condition to not include that post ID I was viewing there, as a demo, but it still showed. I then set it to AND, and it disappears. So surely that means if the other things were still valid, the OR would just be ignored and it wouldn’t show - it was the addition of the AND rule at the end that made it hidden.
No, AND is correct for this (because of the negatives). If it was OR, then the element would show for every post.
Think about it… if you have it as OR… then it means ANY of those conditions can be true for the element to show.
If we simplify your example, and only include the post ID conditions… every single post on your site will be EITHER post ID is NOT 2 OR post ID is not 123. (including post 123 and post 2, because they both aren’t each other)
But to have it so every post apart from 2 and 123 (which is what you’re trying to do) it needs to be both not 2 AND not 123.
Hmm, yeah I kinda see what you’re meaning and you’re right, I understand what I’m trying to do but maybe it’s the negatives?
I guess if I used ORs but with positives, it would be a bit of a different story.
I think my understanding of OR is flawed in that case, as I assumed it just meant if any of these conditions apply, it’s not shown. The AND seemed to me to mean that all of those things had to be true at once, if that makes sense? (i.e the Post ID had to not be 2 AND 123 at the same time.)
Appreciate your help clarifying though, so you’re saying keep using AND in this instance?