Skip Navigation

[Resolved] when I use a wpv_filter_query the ajax mode stops working

This support ticket is created 6 years, 11 months ago. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by Luo Yang 6 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#600001

I am trying to:
I have build a custom filter and it works fine until I switch on ajax refresh.
when I use a wpv_filter_query the ajax mode stops working and when I try to move to next page the spinner shows up but does nothing.

Link to a page where the issue can be seen:

I expected to see:

Instead, I got:

#600103

Dear Oliver,

The filter hook wpv_filter_query should be able to triggered when using AJAX mode and pagination settings, could you describe detail steps to duplicate same problem? and copy/paste your custom PHP codes here, I need duplicate same problem and debug it in my localhost. thanks

#600152

As I mentioned if I dont use 'wpv_filter_query' it works fine

here is snippet of code
add_filter( 'wpv_filter_query', 'host_family_search_engine_shared_cpt' , 10, 3);

function host_family_search_engine_shared_cpt( $query_args, $view_id, $setting ) {
global $WP_Views;
....
if (!empty($_GET["county-search-dropdown"] )) {

$query_args['post__in'] = $values_full;

$index = 0;
if(isset($query_args['meta_query'])){
$index = count($query_args['meta_query'])+1;
}
$query_args['meta_query'][$index] = array(array(
'key' => '_wpcf_belongs_region_id',
'value' => $_GET['county-search-dropdown'],//'9',
'compare' => '='
));

The screen just shows the spinner and hangs

#600377

The question is not clear, in the original post:
https://toolset.com/forums/topic/when-i-use-a-wpv_filter_query-the-ajax-mode-stops-working/#post-600001
You said: when I use a wpv_filter_query the ajax mode stops working
but in the post:
https://toolset.com/forums/topic/when-i-use-a-wpv_filter_query-the-ajax-mode-stops-working/#post-600152
You said: As I mentioned if I dont use 'wpv_filter_query' it works fine/em>

So are you going to use wpv_filter_query to setup custom PHP codes? Does the problem you mentioned above occur after you add the custom PHP codes?

If it is, the PHP codes you provided is not completed, so I can not duplicate same problem, in case there is any compatibility problem, please try this:
1) deactivate other plugins and switch to wordpress default theme, and test again
2) If the problem still persists, please provide a copy of your website, also point out the problem page URL and view URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#600716

I checked your PHP codes, there are some codes are outputting reuslts to the client side, for example:

debug_to_console('Update check 111' . $query . " ======");

It should not exists in wpv_filter_query, in wpv_filter_query filter hook, you should only return the result.

And since it is a custom PHP codes problem, I suggest you debug your codes line by line, from easy to hard, change it to easy some code:

add_filter( 'wpv_filter_query', 'host_family_search_engine_shared_cpt' , 10, 3);

function host_family_search_engine_shared_cpt( $query_args, $view_id, $setting ) {
	if ( $WP_Views->current_view == 14570 || $WP_Views->current_view == 19840000) {
		$query_args['post__in'] = array(123, 456); //replace it with specific post IDs
		return $query_args;
	}
}

Check if the codes works in AJAX mode, if it works then add your custom codes line by line, try to locate the problem codes.