From 05a4178ae086b5ccf3e3a2b1412f05c11a2ce538 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Mon, 27 Nov 2023 13:05:39 +0100 Subject: [PATCH] updating component to make it more flexible --- single-conseils.php | 18 +++++++ .../post-conseils/chapter-header.php | 48 ++++++------------- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/single-conseils.php b/single-conseils.php index 10e026f..7565950 100644 --- a/single-conseils.php +++ b/single-conseils.php @@ -80,9 +80,27 @@ if (!function_exists('build_share_urls')) { post_content); $chapterBlockIndex = build_chapter_index($blocks); + $queryArgs = array( + 'post_type' => 'brochures', + 'posts_per_page' => 1, + 'tax_query' => array( + array( + 'taxonomy' => 'thematiques', + 'field' => 'term_id', + 'terms' => $currentThematique->term_id + ) + ) + ); + $relatedBrochuresPosts = get_posts($queryArgs); + $relatedBrochure = get_field('brochure_pdf', $relatedBrochuresPosts[0]->ID) ?? null; + ?> get_the_ID(), + 'title' => get_the_title(get_the_ID()), + 'ctaUrl' => $relatedBrochure['url'], + 'ctaTitle' => __("Télécharger la brochure ", "homegrade-theme__texte-fonctionnel"), + 'hasInfoCapsule' => true, )); ?>