Hi,
Please refer to this post: https://toolset.com/forums/topic/post-type-filter/
And the comments made by Oliver, after the topic was closed.
We're having the same problem - We're using custom post type filters as checkboxes and initially the first search results are fine. If you then alter your search to use a different combination of custom post types it combines the previous searches and the new search together in the URL parameters.
Search one: (Selecting post types: post and organization)
/?wpv_view_count=10170-TCPID2274&wpv_post_search=rob&wpv-post-type[]=organization&wpv-post-type[]=post
Search Two: (unticking post and organization and checking contact and page)
/?wpv-post-type[]=organization&wpv-post-type[]=post&wpv_view_count=10170-TCPID2274&wpv_post_search=rob&wpv-post-type[]=contact&wpv-post-type[]=page
You can see that in the URL parameter the old checkboxes have been kept.
functions php code:
add_filter( 'wpv_filter_query', 'post_type_filter_func', 10, 3 );
function post_type_filter_func( $query_args, $settings, $view_id ) {
if ( $view_id == 10170 && isset($_GET['wpv-post-type'][0]) && !empty($_GET['wpv-post-type'][0]) ) {
$query_args['post_type'] = $_GET['wpv-post-type'][0];
}
return $query_args;
}
Hi, can you tell me if it makes a difference when you use or disable AJAX to update the View?
Hi Christian,
Thanks for the suggestion -
Selecting either of the Full page load options yields the same result.
However, Enabling either of the AJAX options fixes the issue when selecting one post type checkbox.
For example if I select post type pages then click load it will load the results fine. If we then select pages and contacts, it will only load one post type.
-- I think I have fixed this issue now by changing the functions code to $query_args['post_type'] = $_GET['wpv-post-type']; without the [0].
We'll do some more testing to confirm.
Okay I'll stand by for your update, thanks.