Skip Navigation

[Resolved] No mostrar campo si está vacío

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

Problem:
How to check if custom field value is empty or not and display content conditionally.

Solution:
You can use [wpv-conditional] shortcode in order to display conditional output.

You can find proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/no-mostrar-campo-si-esta-vacio/#post-616621

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/#2-comparing-the-element-with-an-empty-string

This support ticket is created 6 years, 9 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.

Our next available supporter will start replying to tickets in about 2.44 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by nandomerino 6 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#616515

Buenas una vez más,

Tengo este código para mostrar en una plantilla de contenido una selección de vídeos e imágenes (así es como he resuelto poder mostrar imágenes y vídeo en el portfolio), funciona correctamente pero el campo vídeo siempre se muestra aunque no tenga contenido, me gustaría saber si hay alguna forma para que no se imprima el código que muestra el vídeo si ese campo está vacío.

<div class="galeria-proyecto">
[types field='galeria-imagenes' alt='%%ALT%%' title='%%TITLE%%' align='none' ][/types]
<video src="[types field='video1' output='raw'][/types]" loop autoplay></video>
[types field='galeria-imagenes2' alt='%%ALT%%' title='%%TITLE%%' align='none'][/types]
<video src="[types field='video2' output='raw'][/types]" loop autoplay></video>
[types field='galeria-imagenes3' alt='%%ALT%%' title='%%TITLE%%' align='none' ][/types]
<video src="[types field='video3' output='raw'][/types]" loop autoplay></video>
[types field='galeria-imagenes4' alt='%%ALT%%' title='%%TITLE%%' align='none'][/types]
<video src="[types field='video4' output='raw'][/types]" loop autoplay></video>
[types field='galeria-imagenes5' alt='%%ALT%%' title='%%TITLE%%' align='none'][/types]
</div>

Gracias.

#616621

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Nigel is not available today. This is Minesh here and I will try to help you with your issue in English language. Hope this is OK.

You can use [wpv-conditional] shortcode in order to display conditional output.

For example:
-- To check field is empty and display value:

[wpv-conditional if="( '[types field='video1' output='raw'][/types]' eq '' )"]

The email field is empty

[/wpv-conditional]

-- To check field is NOT empty and display value:

[wpv-conditional if="( '[types field='video1' output='raw'][/types]' ne '' )"]

field is not empty 

[/wpv-conditional]

More info:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/#2-comparing-the-element-with-an-empty-string

#616648

Thanks!