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
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.
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 🙂