Skip Navigation

[Resuelto] Conditional in Content Template to check whether a WYSIWYG field is empty or not

This support ticket is created hace 1 año, 9 meses. 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 3 respuestas, has 2 mensajes.

Last updated by Luo Yang hace 1 año, 9 meses.

Assigned support staff: Luo Yang.

Autor
Mensajes
#2022941

Tell us what you are trying to do?
Show or hide some code based on whether or not a WYSIWYG field has any content in it

Is there any documentation that you are following?
https://toolset.com/forums/topic/hide-empty-fields-2/

What is the link to your site?
hidden link

In the example, the 'Reviews' header should be hidden because it's inside a conditional that checks whether the field 'Reviews' has any content. I have tried all the methods I can find but none of them work.

#2022963

Luo Yang
Supporter

Languages: Inglés (English ) Chino simplificado (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hello,

You can setup the wpv-conditional shortcode like this:

[wpv-conditional if="  ( ( $(wpcf-test-wy-1) ne '' ) ) " ]
<p>Not empty</p>
[/wpv-conditional]

Please replace test-wy-1 with your custom WYSIWYG field slug.

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional

#2022965

Unfortunately that doesn't work 🙁

    [wpv-conditional if="( ( $(wpcf-reviews) ne '' ) ) "]
    <h3 class="reviewsheader">Reviews</h2>
    [types field='reviews'][/types]
    [/wpv-conditional]

still shows the H3 heading even when Reviews field is empty.

#2022981

Luo Yang
Supporter

Languages: Inglés (English ) Chino simplificado (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

I have tried it in my localhost with fresh WP installation + the latest version of Toolset plugins, it works fine, please try these:
1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/

2) In case it is a compatibility problem, please deactivate all other plugins, and switch to WordPress default theme 2021, deactivate all custom PHP/JS code snippets, and test again

3) Also check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/

4) If the problem still persists, please provide database dump file(ZIP file) of your website, you can put the package files in your own google drive disk, share the link only, also point out the problem page URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/