homegrade_theme_production/template-components/cards/card-conseils-thematique.php

39 lines
1.7 KiB
PHP

<?php
// $thematique est un post type object term de la taxonomie thematiques
$thematique = $args['thematique'];
$taxonomy_picture = get_field('taxonomy_pictures', $thematique) ?? null;
$color = getThematiqueFamilySlug($thematique->slug);
$args = array(
'posts_per_page' => 1,
'post_type' => 'conseils',
'tax_query' => array(
array(
'taxonomy' => 'thematiques',
'field' => 'term_id',
'terms' => $thematique->term_id,
'include_children' => false
)
)
);
$relatedThematiqueConseilsQuery = new WP_Query($args);
$relatedPostConseil = $relatedThematiqueConseilsQuery->posts[0] ?? null;
?>
<div class="card-thematique card-<?php echo $thematique->slug ?>" data-taxonomy="<?php echo $thematique->slug ?>">
<?php if ($taxonomy_picture && $taxonomy_picture['illustration_s']) : ?>
<img class="card-thematique__thumbnail" src="<?php echo $taxonomy_picture['illustration_s']['sizes']['medium'] ?>" alt="">
<?php endif; ?>
<h3 class="card-thematique__title text-<?php echo getThematiqueFamilySlug($thematique->slug) ?>"><?php echo $thematique->name ?></h3>
<p class="card-thematique__description"><?php echo $thematique->description ?></p>
<a class="card-thematique__cta hover:text-<?php echo getThematiqueFamilySlug($thematique->slug) ?>" href="<?php echo get_permalink($relatedPostConseil->ID) ?>">
<?php echo __("En savoir plus ", "homegrade-theme__texte-fonctionnel") ?>
<span class="sr-only"><?php echo __("sur ", "homegrade-theme__texte-fonctionnel") ?><?php echo $thematique->slug ?></span>
<div class="cta_arrow_button">
<img src='<?php echo get_template_directory_uri() ?>/resources/img/graphic-assets/arrow-right-circle.svg' alt=''>
</div>
</a>
</div>