FEATURE Adapting card to handle post thumbnail

This commit is contained in:
Antoine M 2026-03-03 17:13:18 +01:00
parent 332d905a32
commit 1be5cf1d1b

View File

@ -1,14 +1,15 @@
<?php
$ID = $args['ID'] ?? null;
$current_post_type = $args['current_post_type'] ?? get_post_type();
$types_terms = get_the_terms($ID, 'type');
$type = isset($types_terms[0]) ? $types_terms[0] : null;
$title = get_the_title($ID);
$showExcerpt = $args['show_excerpt'] ?? false;
$excerpt = get_the_excerpt($ID);
$link = get_the_permalink($ID);
$image = get_the_post_thumbnail_url($ID);
$has_post_thumbnail = has_post_thumbnail($ID);
$thumbnail_url = get_the_post_thumbnail_url($ID) ?? null;
$date = get_the_date('F Y', $ID);
$authors = get_field('authors', $ID);
@ -20,13 +21,17 @@ $tags = get_the_terms($ID, 'etiquettes');
?>
<a class="post-card post-card--<?php echo $current_post_type; ?> card" href="<?php echo $link; ?>">
<?php get_template_part('template-parts/components/content-meta', null, array(
'current_post_type' => $current_post_type,
'current_post_id' => $ID
)); ?>
<a class="post-card post-card--<?php echo $current_post_type . ' ' . ($has_post_thumbnail ? 'post-card--has-thumbnail' : ''); ?> card" href="<?php echo $link; ?> ">
<?php if ($has_post_thumbnail) : ?>
<div class="post-card__thumbnail">
<img src="<?php echo $thumbnail_url; ?>" alt="<?php echo $title; ?>">
</div>
<?php endif; ?>
<div class="card__inner">
<?php get_template_part('template-parts/components/content-meta', null, array(
'current_post_type' => $current_post_type,
'current_post_id' => $ID
)); ?>
<div class="card__content">
<h3 class="card__title"><?php echo $title; ?></h3>
<?php if ($showExcerpt) : ?>