Skip Navigation

[Resolved] Custom ShortCode in a HTML conditional

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

Problem:
How can I use a Custom ShortCode in a Views HTML conditional?

Solution:
You will need to register it first in Toolset > Settings > Front End Content > 3rd Party ShortCodes

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-custom-functions-in-conditions/

This support ticket is created 6 years, 10 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
- - 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)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by hossamH-2 6 years, 9 months ago.

Assisted by: Beda.

Author
Posts
#532236

I have the same issue as https://toolset.com/forums/topic/conditional-output-does-not-work-with-custom-shortcode/ of having custom short codes not working in wpv-conditional..

Even something like this does not work..

[wpv-conditional if="( '[my_evaluation]' eq '0' )" debug="true"]
True
[/wpv-conditional]

It doesn't matter that the logic is write or wrong, it doesn't even show the debug information because I am using a custom shortcode [my_evaulation]

However if I substituted my custom shortcode with any shortcode like this..

[wpv-conditional if="( '[wpv-archive-title]' eq '0' )" debug="true"]
True
[/wpv-conditional]

I get a debug screen! Also in your own documentations it says that using the shortcode is limited to admins with manage_option capabilities, so am not sure what is missing as I am seeing other people on the forums working fine with custom short codes and wpv-conditional, so please let me know what is going on..

#532244

I would like to add that it only works for users with admin capabilities, meaning that even if I registered the custom shortcode in toolset settings, there is no way to make it working for site visitors. This is very frustrating.

#532389

What works for admins only is the Debug Information.

Of course, any ShortCode evaluation per se works always, otherwise the point of a Conditional HTML using ShortCodes would not be fulfilled.

I suspect your ShortCode breaks the logic.

Please do this:

1. Paste here the exact function that registers this ShortCode
2. Put your Custom ShortCode in a Post Body or View Loop, and let me know what you see as its output. Do not wrap it in a Conditional. Just put it in an editor and see what it outputs

I suspect your ShortCode is either not returning its result, or it's returning a bad result that breaks the conditions logic.

I am awaiting your data, so I can solve this for you or give a hint how to solve it.

Thank you for your extended patience on weekends, as we have limited resources during these days.

#533330

Sorry for the delay..
It actually has worked after I unregistered the shortcode and re-registered it.
I have another problem though but it should belong to another ticket

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