OR condition not working when two separate conditions are applied

I have a custom post type called Events with a show / hide slider and an available spaces field. I’m displaying this information on the front end using a slider (inline) and it all works great, its been built as a component. I then try to applied conditions to the Slide1 of the slider. I want to either be able to show / hide the event or if the available spaces is zero then hide the event from the slider. I have the following conditions and they each work separately doing exact as I need them to but when they are both applied neither works.

Number: {{dc:acf:post_field field=“event_show”}} == 1
OR
Number: {{dc:acf:post_field field=“event_spaces”}} == 0\

Any ideas why this doesn’t work ?

I can provide access to the staging site if required

Hello @Kennyboy7,

Thanks for writing in! The OR condition will work when one of the conditions is true. It should also work when two of the conditions are true. Make sure that the return value of the ACF field is 1 or 0. If you are not sure, you can use the String condition instead of Number.

If nothing is working, please provide us access to the site. You can create a secure note in your next reply with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
– Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

image

Best Regards.

Hi @ruenel,


Ok so I tried what you suggested and it still doesn’t work but I have discovered something very weird.

I added all the conditions to a single statement i.e not as separate OR condition I added them as AND conditions and this works. The AND conditional logic is working as the OR conditional logic should work.

On the front end this now filters out events that are past todays date or it filters out any where the event_spaces is zero or where the show/hide slider on the post is set to hide. This means that all three conditions are being treated as OR condition but as you can see from the screenshot I have them added as AND conditions.

This is now working as I need it to work but can you explain why this is working in the opposite sense as its very confusing.

I’ve added some login details for you to have a look, it a component called Event Card - Posts and its the top version

Hey @Kennyboy7,

I have logged in and see this:

You added the condition alongside your Looper Provider. The conditions will not work in filtering the returned items of the looper. You should add these conditions with the looper itself.

I think, you do not need the condition if the Looper Provider returns the only event items that you want to be displayed.

Hope this makes sense.

Hi I’ve tried your solution and it does not work. When I apply the conditions as meta values in the query either no posts appear or a single post for a single date appears.
Just to confirm I removed the conditions and then added the meta vales as shown above, all posts are displayed on the front end. I tried various combinations of AND and OR and there is no change all posts are displayed. I tried to add just the date filter I.e only show me post today or in the future and all I got was a single post showing todays post.
As I mentioned it was in the conditions but usi no AND instead of OR and that acts as an OR.

Hello @Kennyboy7,

I have made a demo in the URL found in the secure note below.
The first column is for the event show and the second column is for the event spaces. I also have a column that combines them using the OR logic. If we use the AND logic, only 1 item will display.

Best Regards.

Hi @ruenel,

Thank you so much for making that explanation page - from this I have worked out why it wasn’t working for me. I had included a date condition comparing my event date against todays date, the format of the comparison was different therefore the comparison failed and didn’t show the correct output. I have sorted this now and it all works as I need it to.
Themeco support is second to none and you always go the extra mile to explain things and I thank you, please close this thread as completed.

Hi @Kennyboy7,

Glad that we are able to help you.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.