Skip Navigation

[Resolved] Shortcodes in Conditional block advanced mode condition definition

This support ticket is created 3 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 – 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)

This topic contains 2 replies, has 2 voices.

Last updated by tomasP 3 years ago.

Assisted by: Shane.

Author
Posts
#2211595
Snímek obrazovky 2021-11-03 v 8.21.17.png
Snímek obrazovky 2021-11-03 v 8.16.25.png

Hello,
I have a CPT called Hry and another one called Program.
Hry is a set of theater plays and Program creates calendar entries of where and when Hry items are played.
For a reason I am not using Relationship between those two CPTs, instead each Program entry has u custom Number field to store the ID of a Hry item. In my Template for Program items I am able to read the value of field with corresponding Hry item value and load field content from this item.
I ran into a problem with Conditional block however. I am able to create a condition in Program content template based on a specific Hry item value - see pic. 1 (Snímek obrazovky 2021-11-03 v 8.16.25.png). But I run into a problem when trying to change the "item" value from specific to dynamic. Instead of ' item="3423" ' value I am trying to change it to ' item="[wpv-post-field name='wpcf-predstaveni-id-hry']" ' value. But I am not able to due to incomplete definition warning - see pic. 2 (Snímek obrazovky 2021-11-03 v 8.16.25.png)
This "[wpv-post-field name='wpcf-predstaveni-id-hry']" shortcode worked flawlessly in all the other cases, but not in Conditional block.
Is there any way to make it work, please?
Thanks,
Tom

#2211885

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Do you need the wpv-for-each shortcode? It adds to the depth of the nested shortcodes when using wpv-post-field rather than a static id but is it actually necessary?

It looks like you are testing whether a custom field is empty. The custom field accepts multiple values, which I guess is why you are using the wpv-for-each shortcode to iterate over each value of the field. But if you omit the wpv-for-each shortcode and just test the shortcode output directly, that will test a single value stored for the field (assuming there are multiple values), and you are just checking for empty, so a single value will be enough to satisfy that condition.

I suggest you re-try without the wpv-for-each shortcode.

#2212163

GREAT! Thanks very much for pointing me into the right direction. The wpv-for-each shortcode was generated automatically by Toolset originally.

If anyone ran into similar problem - the correct condition is " NOT ( empty( $(wpcf-hry-youtube).item([wpv-post-field name='wpcf-predstaveni-id-hry'])) ) "

The Conditional block accepts this code but after that it prints "Incomplete condition" in the property box and the condition cannot be edited, but despite this it works 🙂