I am trying to:
Filter views query by custom field value.
add_filter( 'wpv_filter_query_post_process', 'houzez_child_custom_views_post_process_query', 10, 3 );
function houzez_child_custom_views_post_process_query($query, $view_settings, $views_id) {
if ( $views_id == 16920 || $views_id == 16903) {
if ( !empty( $query->posts ) ) {
$results_posts = array();
$all_posts = $query->posts;
foreach ($all_posts as $post) {
$add_infos = get_post_meta( $post->ID, 'wpcf-bien-infos-add', true);
if ( empty($add_infos) || $add_infos != 'Suspendu' ) {
array_push( $results_posts, $post );
}
}
$query->posts = $results_posts;
}
}
return $query;
}
Link to a page where the issue can be seen:
hidden link (login : houseimmo, pwd : 1mm0Hous5).
I expected to see:
11 posts when clicking on the 10-15 MIN link
Instead, I got:
12 posts when clicking on the 10-15 MIN link
Finally worked it out by adding the following lines :
$query->found_posts = count ($results_posts);