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,
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
Thank you very much Waqar. It works perfectly. 🙂