Skip Navigation

[Resolved] conditionals with my shortcodes aren’t working

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

Problem:

Nested custom shortcode does not work in [wpv-conditional], for example:

[wpv-conditional if="( '[types term_id=[parent_id] termmeta=animation output=raw][/types]' != '')"]

Solution:

It is not recommended to use nested shortcodes insider [wpv-conditional] shortcode, I suggest you try these:

https://toolset.com/forums/topic/conditionals-with-my-shortcodes-arent-working/#post-1371859

Relevant Documentation:

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

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by Eugene Mednikov 5 years ago.

Assisted by: Luo Yang.

Author
Posts
#1371775

I'm trying to implement this conditional at archive page:

This works fine: [types term_id='[parent_id]' termmeta='animation' output="raw"][/types]

[parent_id] is my shortcode that returns taxonomy term parent (0 or number)

This also works: [wpv-conditional if="( '[types termmeta=animation output=raw][/types]' != '')"]

But this fails (e.g. it's always false): [wpv-conditional if="( '[types term_id=[parent_id] termmeta=animation output=raw][/types]' != '')"]

Tried with quotes, same result: [wpv-conditional if="( '[types term_id='[parent_id]' termmeta='animation' output='raw'][/types]' != '')"]

#1371859

Hello,

It is not recommended to use nested shortcodes insider [wpv-conditional] shortcode, I suggest you try these:
1) Create a content template, for example: my-term-meta, using below content:

[types term_id='[parent_id]' termmeta='animation' output='raw'][/types]

2) Modify your codes as below:

[wpv-conditional if="( '[wpv-post-body view_template="my-term-meta" suppress_filters="true"]' != '')"]
... here display something ...
[/wpv-conditional]
#1372203

ok, I've made a function to compute this shortcode and used it at conditional