diff --git a/search.php b/search.php index 2fb5b6c..a5a6be4 100644 --- a/search.php +++ b/search.php @@ -190,11 +190,33 @@ if ( $search_query ) { if ( ! is_wp_error( $matching_terms ) ) { foreach ( $matching_terms as $term ) { $tax_obj = get_taxonomy( $term->taxonomy ); + // Comptage réel, mêmes critères que taxonomy.php : $term->count n'est pas + // fiable sur ces taxonomies Pods, sans object_type (WordPress le remet à 0). + $count_query = new WP_Query([ + 'post_type' => 'post', + 'post_status' => 'publish', + 'fields' => 'ids', + 'posts_per_page' => 1, + 'tax_query' => [ + 'relation' => 'AND', + [ + 'taxonomy' => $term->taxonomy, + 'field' => 'term_id', + 'terms' => [ $term->term_id ], + ], + [ + 'taxonomy' => 'category', + 'field' => 'term_id', + 'terms' => [ thalim_cat_id('seance') ], + 'operator' => 'NOT IN', + ], + ], + ]); $taxonomy_cards[] = [ 'name' => $term->name, 'url' => get_term_link( $term ), 'taxonomy_label' => $tax_obj ? $tax_obj->labels->singular_name : $term->taxonomy, - 'count' => $term->count, + 'count' => $count_query->found_posts, ]; } }