From fe14cc2ad227409e6c29579d115718fdc4446be9 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Wed, 13 May 2026 11:57:54 +0200 Subject: [PATCH] FEATURE Adapting content meta to handle dynamiques posts --- template-parts/components/content-meta.php | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/template-parts/components/content-meta.php b/template-parts/components/content-meta.php index 445d7d3..3302f50 100644 --- a/template-parts/components/content-meta.php +++ b/template-parts/components/content-meta.php @@ -3,20 +3,31 @@ $current_post_id = $args['current_post_id'] ?? get_the_ID(); $current_post_type = $args['current_post_type'] ?? null; $type = null; $current_post_type_supports_type = get_post_type_supports_type($current_post_type); - +$is_dynamiques_post_type = $current_post_type === 'revues' || $current_post_type === 'articles'; $hasNumerotation = hasPostTypeNumerotation($current_post_type); -if ($current_post_type_supports_type) { +if ($is_dynamiques_post_type) { + $current_post_type_obj = get_post_type_object($current_post_type); + $dynamiques_post_type_labels = array( + 'revues' => __('Revue', 'carhop'), + 'articles' => __('Article', 'carhop'), + ); + + $type = $current_post_type_obj->labels->singular_name ?? $dynamiques_post_type_labels[$current_post_type] ?? null; +} + +else if ($current_post_type_supports_type) { // $type = isset($types_terms[0]) ? $types_terms[0] : null; $type_term = get_post_specific_type_terms($current_post_id)[0] ?? null; if ($type_term) { $type = $type_term->name; } - // $current_post_type === 'analyses-etudes' && is_array($type) && !empty($type) && isset($type[0]->name -} else { +} + +else { $current_post_type_obj = get_post_type_object($current_post_type); - $type = $current_post_type_obj->labels->singular_name; + $type = $current_post_type_obj->labels->singular_name ?? null; } ?> @@ -28,8 +39,6 @@ if ($current_post_type_supports_type) {