Skip Navigation

[Resolved] Using shortcode in conditional if

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

Problem:

The problem here was that the user's custom shortcode wasn't working in our Toolset conditional code.

Solution:

In order for custom shortcodes to work with our Toolset Conditional shortcode you need to register the shortcode at Toolset -> Settings -> Frontend and under 3rd Party shortcode arguments you will add the name of your shortcode.

This support ticket is created 3 years, 11 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by lesT 3 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#1943099

Tell us what you are trying to do?
I asked something similar in #1924703
I am attempting to perform:
[wpv-conditional if="( '[loop15]' eq '1' )"]
[wpv-post-body view_template="loop-item-in-pilots-child-view"][/wpv-conditional]
where this snippet is save in Toolset>settings>Custom code under [loop15]
I have also tried it under the snippet plugin

The corresponding snippet is as follows, I can't get the if condition to respond to the output-
global $loop_n;
if ( !isset( $loop_n ) ) {
$loop_n = 0;
return 0;
}
$loop_n++;
if ($loop_n > 15)
return 1;
else
return 0;
}};

#1944207

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Les,

Thank you for getting in touch. In order for custom shortcodes to work with our Toolset Conditional shortcode you need to register the shortcode at Toolset -> Settings -> Frontend and under 3rd Party shortcode arguments you will add the name of your shortcode.

Please let me know if it works after this.
Thanks,
Shane

#1945825

My issue is resolved now. Thank you!

My confusion was thinking entering a name on the custom code was the same as registering it on the front end. Maybe you should have note on the custom code page to point out the necessity to do this if the code is to be returning a value into a conditional if
Regards