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;