Skip Navigation

[Resolved] Custom fields and conditional html output not working in VC Grid Builder

This support ticket is created 6 years, 8 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 3 voices.

Last updated by Christian Cox 6 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#664435
Captura de pantalla 2018-04-14 a las 12.09.46.png

I am trying to: Set up a conditional html output in Visual Composer Grid Builder to show custom fields if not empty

I expected to see: The custom field content

Instead, I got: Nothing.

I used this shortcode:

[wpv-conditional if="( NOT(empty($(wpcf-featuring))) )"][types field='featuring' separator=', '][/types][/wpv-conditional]

#664763

1. Does the field itself output something if you remove the Condition?
2. Did you insert this with the GUI or manually?

In theory, that ShortCode should be using {!{shortcode here}!} syntax and not the usual [shortcode].
This is a compatibility layer that we added so our shortcodes can be executed when we need them.

It seems you copy pasted that from another editor.

Please try to insert first the field only, using the GUI.
When the field holds a value, does it display?
If yes, then as well wrap it in an HTML condition, using the GUI.
It should produce the syntax mentioned above.

#666941
Captura de pantalla 2018-04-15 a las 11.08.40.png
Captura de pantalla 2018-04-15 a las 11.03.29.png

Hi Beda, Than you for your help..

1. The shortcode doesn't output someting with or without condition.
2. I tried to create the shortcode with the GUI. The shortcode is insterted in a text field, prior to ask support I tried to put the field with the embed GUI in text editor, also using the GUI in WP backend menu, and the shortcode was always the same:

[wpv-conditional if="( $(wpcf-featuring) eq '' )" evaluate="false"][types field='featuring' separator=', '][/types][/wpv-conditional]

As those didn't work I also copy/paste the conditional shortcode from Toolset documentation.

No GUI gave me a code as yours. Then I wrote this one in a editor and copy/paste:

{!{wpv-conditional if="( $(wpcf-featuring) eq '' )" evaluate="false"}!}{!{types field='featuring' separator=', '}!}{!{/types}!}{!{/wpv-conditional}!}

but it doesn't work. With [...] nothing is shown in frontend, with {!{...}!} the shortcode is shown in frontend

Then I wrote you...

The only way to obtain some results is using VC field "Custom Field" with toolset custom field name wpcf-xxx but it doesnt work because with this field I can't use conditions.

Remember we are talking about Visual Composer Grid Builder (in the VC editor shortcodes works as expected).

#668623

Hi, I can see that you're having trouble using shortcodes inside the WPBakery Page Builder's Grid Builder feature. At this time, our custom field shortcodes are not well-integrated here because the grid builder creates its own loop. Our shortcodes do not have access to the main post's ID here. Other Users have noticed this issue and we submitted a feature request to add this functionality, but this request has not been implemented yet by our developers. You can see Beda's previous response about this here: https://toolset.com/forums/topic/unable-to-display-types-field-within-visual-composer-grid-builder/#post-565834

I have added your vote to this feature so our developers are aware that more people are requesting this integration, but at this time I do not have a delivery timeline available. If you are able to access the post's ID somehow in the Grid Builder loop using a shortcode, you can pass that shortcode into the types field shortcode like this:

{!{wpv-conditional if="( [wpv-post-field id='[some_post_id_shortcode]'] eq '' )" evaluate="false"}!}{!{types field='featuring' separator=', ' id='[some_post_id_shortcode]'}!}{!{/types}!}{!{/wpv-conditional}!}