Saltar navegación

[Resuelto] Replacing the query in a View via PHP

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.

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 -

Zona horaria del colaborador: Asia/Kolkata (GMT+05:30)

Este tema contiene 1 respuesta, tiene 2 mensajes.

Última actualización por Minesh 2 years ago.

Asistido por: Minesh.

Autor
Mensajes
#2701304

Hi there,

I want to do something a little bit strange in Toolset: I want to create a slider (View) but feed its content via PHP code. Why do this? Because the typical options available in the GUI dashboard interface for Views don't provide the level of flexibility I need from a WP_Query object. In other words, I have a very complex query which I can't express through the visual interface. However, I want to make use of Toolset's ability to output the information in a pre-built format (in this case, a slider).

Is there a way to do this? For example, should I hook into pre_get_posts and just replace all of the arguments?

Thank you.

Saul

#2701345

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You can use the view's filter hook "wpv_filter_query" in order to override the query filter argument on fly.
- https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

Where using above hook you can hook in meta_query or tax_query or any other possible arguments.

#2701447

Thanks, Minesh! I appreciate your help!

Saul