hello,
I use the below code to not display items until a filter is clicked:
function tssupp_no_initial_results( $query_results, $view_settings, $view_id ){
$page_id = get_the_ID();
if($page_id == 627 || $page_id == 690 || $page_id == 567 || $page_id == 656) {
// if there is a search term set
if ( !isset( $query_results->query['meta_query'] ) && !isset( $query_results->query['tax_query'] ) && !isset( $query_results->query['s'] ) ) {
$query_results->posts = array();
$query_results->post_count = 0;
$query_results->found_posts = 0;
}
}
return $query_results;
}
add_filter( 'wpv_filter_query_post_process', 'tssupp_no_initial_results', 99, 3 );
instead this code to add a custom meta_query, I needed to add a custom one because the below mentioned costum field is only used by one of the post type declared in the query
add_filter( 'wpv_filter_query', 'hide_costum_field_post', 10, 3 );
function hide_expired_events( $query_args, $view_settings, $views_id ) {
$page_id = get_the_ID();
if ($page_id == 690) {
if (!isset($_GET['wpv_filter_submit']) ) { // if it is specific view and by default
$query_args['meta_query'][] = array(
'relation' => 'OR',
array(
'key' => 'wpcf-evento_privato',
'value' => 0,
'compare' => '=',
'type' => 'NUMERIC'
),
array(
'key' => 'wpcf-evento_privato',
'compare' => 'NOT EXISTS'
)
);
}
}
return $query_args;
}
My problem is that adding the last code below, the first code is like it doesn't get executed (obviously because there is !isset( $query_results->query['meta_query'] )), however I would like to be able to add the meta query additional and do not display the items until the filters are clicked