Skip Navigation

[Resolved] How to use wpv_filter_query

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
- 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)

This topic contains 2 replies, has 2 voices.

Last updated by lotharK 1 year, 3 months ago.

Assisted by: Waqar.

Author
Posts
#2520253

As far as I understand, I can filter a view with custom PHP. (The existing filter options are not enough in my case.) I have found several articles that describe how this should work, but for me already the hook does not work. Maybe you can help me.

I have set up a test installation here hidden link.

On the home page, I added a view via shortcode [wpv-view name="list-posts"].
In the functions.php I try to use the hook "wpv_filter_query". I use the Query Monitor plugin to debug the code (QM::...).

The code in functions.php is:

QM::error('a');
add_filter('wpv_filter_query', 'post_type_filter_func', 99, 3);
function post_type_filter_func($query_args, $settings, $view_id)
{
QM::error('b');
// code ...
return $query_args;
}

While "a" is output in the log, the "post_type_filter_func" function does not seem to be triggered (query monitor message "b"). What am I doing wrong? Can you nudge me in the right direction?

Thanks a lot!

#2520799

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

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

I tested the code that you shared on my test website and it worked as expected.

Then I also tested your website's homepage after clearing the view's cache from WP Admin -> Toolset -> Views and was able to see both errors in the log.
( screenshot: hidden link )

You'll find more details on how the internal cache works for the view's output, in this reply:
https://toolset.com/forums/topic/caching-of-several-views-not-working-although-activated/#post-2380085

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

regards,
Waqar

#2521925

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.