Skip Navigation

[Resolved] Conditionals not working

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a conditional that is not working as expected on all posts.

Solution: Change the conditional to test for a taxonomy term instead of a custom field in this case.

This support ticket is created 4 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by abbyJ-2 4 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#2035795

Tell us what you are trying to do? Trying to get a certain conditional to work. It works on one post, but not on the rest. I want illustrators to show when they assigned to a post and not show when they are not.

Is there any documentation that you are following? Checked and few and followed all tutorials and I seem to be doing it correctly, but not getting the desired outcome 100% of the time.

Is there a similar example that we can see? No.

What is the link to your site? Here's a view of the post that is working: hidden link, other posts with illustrators are not functioning correctly. For example, this post should have an illustrator attributed to it: hidden link

Can give logins upon request.

#2035853

Hello, I can help troubleshoot conditionals. If you provide logins in the private reply fields here, I can log in to wp-admin and see how everything is set up.

#2035941
Screen Shot 2021-04-28 at 2.55.56 PM.png

Okay I can see your conditional used the following criteria:

 NOT ( empty( '[wpv-post-field name="illustrator" ]') ) 

This conditional was looking for the contents of a custom field with the slug "illustrator", but I don't see that custom field visible in the post editor. I see a taxonomy called Illustrator, that includes a term indicating the specific Illustrator. Perhaps this worked on some posts because there was previously a custom field used to hold the Illustrator's name? That field could still be in the database, which is why it works for some posts but not others. The conditional logic should be adjusted if you're trying to test whether or not a taxonomy term exists, instead of a custom field value. I've made that adjustment as you can see in the screenshot here, and it seems to be working now on the two posts you shared. Can you do a quick review and see if this is more like you expected?

#2035985

My issue is resolved now. Thank you! -Christian, I swear I'm a complete airhead. You hit the nail on the head. I did originally have it as a custom field, so that's where I was confusing myself. You have it perfectly now. Taxonomies is where the illustrator term is now. Thank you for clarifying my own mind. 😉