Skip Navigation

[Résolu] HTML Conditional is not working as expected for no obvious reason

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
My HTML Conditional does not work, even though visually the syntax is correct and it should expectedly work.
This is the syntax example:

[wpv–conditional if="( '[wpv-post-taxonomy type='related' format='slug']' ne '' )"] NOTHING[/wpv–conditional]

Solution:
Sometimes it can happen that unexpected hidden formatted text gets copied when you copy the code from a Webpage.
It's a good idea to convert into plain text before inserting into the editors if you experience unexplainable failure of HTML conditions (and other HTML) in general.

Often it's good to just generate the conditions using the GUI if possible.
That'll ensure a pure output that is generated with bare text.

This support ticket is created Il y a 4 années et 10 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 réponses, has 2 voix.

Last updated by martinE-4 Il y a 4 années et 10 mois.

Assisted by: Beda.

Auteur
Publications
#1269719
The_Art_of_Changing_the_World__ACW__2017_Report_–_ICASC_MIgration_1.jpg

I am trying to:
Use the wpv-post-taxonomy shortcode to test if a post has at least one term assigned.

using this doc:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/

here is my code:

[wpv–conditional if="( '[wpv-post-taxonomy type='related' format='slug']' ne '' )"] NOTHING[/wpv–conditional]

Note: 'related' is the slug for my custom taxonomy for the custom post type I am using on this page

Instead, I got:
unparsed shortcode output to the screen.

#1269765
Bildschirmfoto 2019-06-15 um 16.16.36.png

That's strange, as it works just fine locally when following the DOC at https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/#one.
I think your code has a mistake since the exact copy of it fails as well with me locally.

This is your code:

[wpv–conditional if="( '[wpv-post-taxonomy type='related' format='slug']' ne '' )"] 
  NOTHING
[/wpv–conditional]

This is the code in the DOC:

[wpv-conditional if="('[wpv-post-taxonomy type='foreign-language' format='slug' ]' ne '' )"]
  WHATEVER
[/wpv-conditional]

The only difference I was able to find with diff checker are a few spaces in the conditional.
And a very confusing difference between your [wpv–conditional, and mine, [wpv-conditional, which are both identical, but not shown as identical by diff checker, and your version ([wpv–conditional) breaks.

Whatever the difference is, I cannot spot it, but if you copy my version ([wpv-conditional) it will work.
Can you spot the difference?
I can't, but this seems to be the issue after all.

#1269905

Apparently there were some invisible garbage characters embedded in my copy of the conditional that disappeared when I scrubbed the text clean by making it plain text. My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.