69 lines
2.2 KiB
PHP
69 lines
2.2 KiB
PHP
<?php
|
|
|
|
|
|
$thematique = get_the_terms($args['postID'], 'thematiques')[0] ?? null;
|
|
$thematique_generale = $thematique->parent ? get_term($thematique->parent, 'thematiques') : $thematique;
|
|
$thematique_generale_id_fr =
|
|
apply_filters('wpml_object_id', $thematique_generale->term_id, 'thematiques', TRUE, 'fr');
|
|
|
|
|
|
// Récupère la source de l'image par rapport à l'ID FR pour s'assurer de bien synchroniser les images dans les deux langues
|
|
$thematique_picture = get_field('taxonomy_pictures', "thematiques_" . $thematique_generale_id_fr)['illustration_s'] ?? null;
|
|
$lastUpdate = get_the_modified_date('', $args['postID']);
|
|
|
|
$queryArgs = array(
|
|
// 'fields' => 'ids',
|
|
'post_type' => 'brochures',
|
|
'posts_per_page' => 1,
|
|
'tax_query' => array(
|
|
array(
|
|
'taxonomy' => 'thematiques',
|
|
'field' => 'term_id',
|
|
'terms' => $thematique->term_id
|
|
)
|
|
)
|
|
);
|
|
|
|
|
|
$relatedBrochuresPosts = get_posts($queryArgs);
|
|
$relatedBrochure = get_field('brochure_pdf', $relatedBrochuresPosts[0]->ID) ?? null;
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
<section class="post-conseils-chapter-header">
|
|
<div class="post-conseils-chapter-header__infos">
|
|
<?php if ($thematique->parent == 0) : ?>
|
|
|
|
<p class="post-conseils-chapter-header__page-thematic-title"><?php echo __("Les conseillers Homegrade vous guident", "homegrade-theme__texte-fonctionnel") ?></p>
|
|
<?php else : ?>
|
|
<p class="post-conseils-chapter-header__page-thematic-title "><?php echo $thematique_generale->name ?></p>
|
|
<?php endif; ?>
|
|
|
|
|
|
<h1 class="post-conseils-chapter-header__page-title"><?php echo get_the_title($args['postID']) ?></h1>
|
|
|
|
<?php if ($relatedBrochure) : ?>
|
|
<?php
|
|
// echo '<pre>';
|
|
// print_r($relatedBrochure);
|
|
// echo '</pre>';
|
|
?>
|
|
<a class="cta cta--primary cta--button" href="<?php echo $relatedBrochure['url'] ?>" target="_blank">
|
|
<?php
|
|
echo __("Télécharger la brochure ", "homegrade-theme__texte-fonctionnel")
|
|
?><span class="sr-only"><?php echo $relatedBrochure['title'] ?></span> </a>
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
get_template_part('template-components/post-infos-capsule', null, array(
|
|
"postID" => $args['postID'],
|
|
"modified" => $lastUpdate
|
|
));
|
|
?>
|
|
|
|
</div>
|
|
<img class="post-conseils-chapter-header__page-thematic-cover " src="<?php echo $thematique_picture['url'] ?>" alt="">
|
|
</section>
|