Skip Navigation

[Resuelto] How to put an item in a loop in bold according to a condition

This support ticket is created hace 4 años, 12 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/Karachi (GMT+05:00)

Etiquetado: ,

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por Francisco Ramón Molina Busquiel hace 4 años, 12 meses.

Asistido por: Waqar.

Autor
Mensajes
#1394673
sc02.png
sc01.png

Hi,
How can I put an item in a loop in bold according to the value it contains.
On my website if a related field is of type "Cartón 12.7 mm" I want it to be shown in bold, but I don't want to use its description "Cartón 12.7 mm" to determine if it meets the condition, maybe its "post id" or its "slug".
How can this be done?
Look at the screenshots.

Thanks for your help.
Regards,

#1395079

Hi Francisco,

Thank you for contacting us and I'd be happy to assist.

For a conditional comparison like this, you can use "wpv-conditional" shortcode, as explained in this guide:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/

Example:


[wpv-conditional if="( '[wpv-post-title item="@tipo-mandril.parent"]' eq 'Cartón 12.7 mm' )"] 
<td><strong>[wpv-post-title item="@tipo-mandril.parent"]</strong></td>
[/wpv-conditional]

[wpv-conditional if="( '[wpv-post-title item="@tipo-mandril.parent"]' ne 'Cartón 12.7 mm' )"] 
<td>[wpv-post-title item="@tipo-mandril.parent"]</td>
[/wpv-conditional]

The above block will show bold title only if it matches the provided text ( i.e. "Cartón 12.7 mm" ) and if it is different, normal title will be shown.

If you'd like to compare that text dynamically, you can replace it with "wpv-post-title" shortcode as well, so that it gets the title of the post with ID 427 ( which is "Cartón 12.7 mm" ).
( ref: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-title )

Example:


[wpv-conditional if="( '[wpv-post-title item="@tipo-mandril.parent"]' eq '[wpv-post-title item="427"]' )"] 
<td><strong>[wpv-post-title item="@tipo-mandril.parent"]</strong></td>
[/wpv-conditional]

[wpv-conditional if="( '[wpv-post-title item="@tipo-mandril.parent"]' ne '[wpv-post-title item="427"]' )"] 
<td>[wpv-post-title item="@tipo-mandril.parent"]</td>
[/wpv-conditional]

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1395251

Thank you very much Waqar. It works perfectly. 🙂