Skip Navigation

[Resuelto] conditional – comments number – not working

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:

Show a different image if there are comments/no comments

Solution:

You can try shortcode [wpv-post-comments-number] like this:

https://toolset.com/forums/topic/conditional-comments-number-not-working/#post-1249021

Relevant Documentation:

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-comments-number

This support ticket is created hace 5 años, 6 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Etiquetado: ,

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por Ido Angel hace 5 años, 6 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#1248989

hey,
in trying to show a different image if there are comments/no comments, i've placed this in the post view:

[wpv-conditional if="( '[wpv-post-comments-number]' gt '0' )"]<img src="<em><u>enlace oculto</u></em>">[/wpv-conditional]

but it doesn't work - no matter how many comments there are, i still get the same image.
any ideas?
thx!

#1249021

Hello,

The shortcode [wpv-post-comments-number] will output:
No Comments
1 Comment
...

You can modify the shortcodes as below, and test again:

[wpv-conditional if="( '[wpv-post-comments-number none="0"]' gt '0' )"]<img src="<em><u>enlace oculto</u></em>">[/wpv-conditional]

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-comments-number
none:
' Text if there are no comments

#1249057

Thanks!
Actually it should be:

[wpv-conditional if="( '[wpv-post-comments-number none="0"]' eq '1' )"]<img src="<em><u>enlace oculto</u></em>">[/wpv-conditional]

since the value after "eq" is a value, not a number...
works!
thx