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:
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
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
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/
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.