Skip Navigation

[Resolved] Shortcode not parsing within conditional + added to third-partty arguments

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

Problem:

A third-party shortcode worked on its own, but it did not parse when placed inside a [wpv-conditional] in Elementor, even after being added under Toolset’s third-party shortcode arguments.

Solution:

The issue was caused by the rendering context. Toolset can process registered third-party shortcodes nested inside Toolset shortcodes when they are rendered in a Toolset context such as a Content Template, but not reliably when the raw conditional is placed directly inside an Elementor widget. The solution was to move the conditional and nested shortcode into a Toolset Content Template and then output that Content Template in Elementor. The customer confirmed this worked.

Relevant Documentation:

https://toolset.com/documentation/legacy-features/views-plugin/using-shortcodes-in-conditions/

https://toolset.com/documentation/legacy-features/views-plugin/shortcodes-within-shortcodes/

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.

This topic contains 1 reply, has 1 voice.

Last updated by benS-19 5 days, 2 hours ago.

Assisted by: Christopher Amirian.

Author
Posts
#2867868

Hi,

I've got the following conditional within Elementor:

[wpv-conditional if="( $(wpcf-instant-wins) eq '1' )"]
<h3>[lty_instant_win_prizes_count] Instant Wins</h3>
[/wpv-conditional]

^ Although it doesn't parse on the page, despite adding it to third party arguments. Take it out of the toolset conditional, and it parses and displays fine on the front-end (as you would expect).

So my question is, even with the addition to the third-party arguments, why isn't it parsing and how can I get it to, please?

Thank you.

#2867876

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Welcome to Toolset support. Registering [lty_instant_win_prizes_count] under Toolset → Settings → Front-end Content → Third-party shortcode arguments is the correct and required step for using a non-Toolset shortcode with a [wpv-conditional], so that part is right. Two constraints are worth ruling out, though neither is likely your blocker since the shortcode renders fine on its own:

- Toolset processes nested shortcodes only one level deep.
- Conditions containing special characters (single or double quotes, dollar signs) can fail to evaluate — but that applies to the if expression, not to your output, so it shouldn't affect the [lty_instant_win_prizes_count] inside the <h3>.

The pattern that matters here: the nested-shortcode processing that "Third-party shortcode arguments" enables is something Toolset does within its own rendering context. That context is a Content Template — that's where a registered third-party shortcode nested inside a Toolset shortcode is expected to be parsed. When the raw [wpv-conditional] is placed directly into an Elementor widget, Elementor outputs the conditional but the inner [lty_instant_win_prizes_count] isn't handed back to Toolset to process, so it comes through unparsed. That's consistent with it working when you take it out of the conditional (Elementor/WordPress parses the lone shortcode directly).

See if you take the condition back to the Toolset content template it will work?

[wpv-conditional if="( $(wpcf-instant-wins) eq '1' )"]<h3>[lty_instant_win_prizes_count] Instant Wins</h3>[/wpv-conditional]

Then output that Content Template where you need it (assign it to the post type, or insert it into the Elementor layout as a Toolset Content Template) instead of placing the raw conditional in a text/HTML widget.

To confirm the cause before rebuilding, paste the exact same conditional into a Content Template (or the native WordPress editor) and preview it — if it renders there, the issue is isolated to how the shortcode is being processed inside Elementor.

For more information:

1) https://toolset.com/documentation/legacy-features/views-plugin/using-shortcodes-in-conditions/

2) https://toolset.com/documentation/legacy-features/views-plugin/shortcodes-within-shortcodes/

Thanks.

#2867890

Thank you for explaining the situation in such great detail, we've moved the logic to a Content Template and it seems to have worked perfectly. Thank you.