'contenu_general', 'posts_per_page' => 1, 'orderby' => 'ID', 'order' => 'ASC', ]); $gc_post = $gc_posts[0] ?? null; if ( $gc_post ) { $context['gc'] = [ 'umr' => thalim_bilingual( $gc_post->umr ?: '', $current_lang ), 'thalim' => thalim_bilingual( $gc_post->thalim ?: '', $current_lang ), 'siecles' => thalim_bilingual( $gc_post->siecles ?: '', $current_lang ), 'presentation' => ( $current_lang === 'en' && $gc_post->presentation_en ) ? $gc_post->presentation_en : $gc_post->presentation, 'presentation_detail' => ( $current_lang === 'en' && $gc_post->presentation_detail_en ) ? $gc_post->presentation_detail_en : $gc_post->presentation_detail, ]; } else { $context['gc'] = []; } $context['current_language'] = $current_lang; // Axes thématiques courants (annee_fin >= current year) for navigation dropdown $current_year = (int) date('Y'); $all_axes = get_terms(['taxonomy' => 'axe_thematique', 'hide_empty' => false, 'orderby' => 'name']); $axes_courants = []; if (!is_wp_error($all_axes)) { foreach ($all_axes as $axe) { $fin = (int) get_term_meta($axe->term_id, 'annee_fin', true); if ($fin >= $current_year) { $link = get_term_link($axe); if (!is_wp_error($link)) { $axes_courants[] = [ 'name' => thalim_bilingual($axe->name, $current_lang), 'link' => $link, 'ordre' => (int) get_term_meta($axe->term_id, 'ordre_daffichage', true), ]; } } } usort($axes_courants, fn($a, $b) => $a['ordre'] <=> $b['ordre']); } $context['axes_courants'] = $axes_courants; // Annonces page URL (language-aware) $annonces_page = get_page_by_path('annonces'); $annonces_base = $annonces_page ? get_permalink($annonces_page->ID) : home_url('/annonces/'); $context['annonces_url'] = $annonces_base; // Language switcher $context['languages'] = thalim_language_switcher(); return $context; } add_filter('timber/context', 'add_to_context');