From 83cb5db5b2f23ffed428386dbf7159e2be1d1776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Wed, 16 Jun 2021 18:28:22 +0200 Subject: [PATCH] Ticket 105: changed get_posts_years_array in functions.php to take 'en' slug versions --- content/themes/ldc/functions.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/content/themes/ldc/functions.php b/content/themes/ldc/functions.php index 49397ba1..8a9e0bb1 100644 --- a/content/themes/ldc/functions.php +++ b/content/themes/ldc/functions.php @@ -312,12 +312,18 @@ add_action('wp_ajax_nopriv_filter_posts', 'ajax_filter_get_posts'); function get_posts_years_array($cat) { $years = []; + $concernedSlugs = [ + 'presentation', 'presentation-en', + 'documents', 'documents-en', + 'meetings', + ]; + $cat_id = $cat->term_id; $args = array( 'cat' => $cat_id, 'posts_per_page' => -1 ); $query = new WP_Query( $args ); // Start the wordpress loop! if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); - if ($cat->slug === 'presentation' || $cat->slug === 'documents' || $cat->slug === 'meetings') { + if (in_array($cat->slug, $concernedSlugs)) { $exercice = get_field('exercice'); if ($exercice !== NULL) $arrays[] = $exercice['value']; @@ -330,7 +336,7 @@ function get_posts_years_array($cat) { return $years; $uniq_arrs = array_unique( $arrays ); foreach($uniq_arrs as $arr) { - if ($cat->slug === 'presentation' || $cat->slug === 'documents' || $cat->slug === 'meetings') { + if (in_array($cat->slug, $concernedSlugs)) { $years[$arr] = $arr; }else{ $years[$arr] = ($arr - 1) . '/' . $arr;