Skip Navigation

[Resuelto] Display Conditions if Post in View Matches the Current Page

This support ticket is created hace 6 meses, 2 semanas. 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)

Este tema contiene 1 respuesta, tiene 2 mensajes.

Última actualización por Waqar hace 6 meses, 2 semanas.

Asistido por: Waqar.

Autor
Mensajes
#2697682

I have a related products View on a single product page layout that I wish to display conditional styles based on if the post in the View output matches the current page.

I have the view built out (enlace oculto) and you can see what I'm attempting to replicate from the mockup here: enlace oculto

I suppose I could work in a strictly CSS or jQuery solution, but I wanted to see if I could use Toolset's Conditional Arguments to conditionally display a class name in the loop output that specifically applies the styles I'm looking to apply. The class I'm intending on using is simply gonna be labeled "disabled" and I'm going to have the styles already worked into stylesheet.

Any help in this manner would be greatly appreciated. Thanks in advance!

#2697747

Hi,

You can use the attribute item="$current_page" in Toolset shortcodes, to get the information from the current page:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

For example, to get the ID of the current page, you can use the 'wpv-post-id' shortcode, like this:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-id


[wpv-post-id item="$current_page"]

The same shortcode can be used in the conditional statement in a view's loop to compare the current page's ID and the current loop result's ID:


<div [wpv-conditional if="( '[wpv-post-id]' eq '[wpv-post-id item="$current_page"]' )"]class="current"[/wpv-conditional]>
......
</div>

regards,
Waqar

#2698022

Brilliant! This works as advertised (enlace oculto). Thank you for the assistance.