Skip Navigation

[Resolved] Conditional Shortcode not working

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

Problem: I have a conditional tag that does not appear to be working correctly.

Solution: Check the syntax and try nesting double quotes and single quotes like this:


This support ticket is created 6 years, 7 months 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 2 replies, has 2 voices.

Last updated by brianD-10 6 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#627883
conditional.jpg

I am trying to: Use the conditional shortcode

Link to a page where the issue can be seen: hidden link

I expected to see: Tests to display "working" text with conditional shortcode.

Instead, I got: Nothing is displayed.

Reference: https://toolset.com/documentation/beyond-the-basics/conditionally-show-content/

#628131

I think you're seeing some problems with nested quotation marks. I made the following changes:

Conditional using squigly brace test:

{!{wpv-conditional if="( $(wpcf-tagline2) ne '' )"}!}Works{!{/wpv-conditional}!}

Conditional using shortcode test:

[wpv-conditional if="( $(wpcf-tagline2) ne '' )"]Works[/wpv-conditional]

End.

Now I see "Works" appear in both locations. Can you confirm?

#628453
button.jpg

Gotcha, thanks! FYI the broken shortcode was produced by your WYSIWYG button, so you should probably note this as a bug. See attached screenshot.