Recherche : nombre réel de publications par programme et par axe
Le compteur enregistré de ces taxonomies Pods n'est pas fiable : sans object_type, WordPress le remet à 0 à chaque ajout ou retrait de terme, et le nombre disparaissait du bloc de résultats. Il est désormais calculé à l'affichage, avec les mêmes critères que l'index du terme.
This commit is contained in:
+23
-1
@@ -190,11 +190,33 @@ if ( $search_query ) {
|
|||||||
if ( ! is_wp_error( $matching_terms ) ) {
|
if ( ! is_wp_error( $matching_terms ) ) {
|
||||||
foreach ( $matching_terms as $term ) {
|
foreach ( $matching_terms as $term ) {
|
||||||
$tax_obj = get_taxonomy( $term->taxonomy );
|
$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[] = [
|
$taxonomy_cards[] = [
|
||||||
'name' => $term->name,
|
'name' => $term->name,
|
||||||
'url' => get_term_link( $term ),
|
'url' => get_term_link( $term ),
|
||||||
'taxonomy_label' => $tax_obj ? $tax_obj->labels->singular_name : $term->taxonomy,
|
'taxonomy_label' => $tax_obj ? $tax_obj->labels->singular_name : $term->taxonomy,
|
||||||
'count' => $term->count,
|
'count' => $count_query->found_posts,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user