carhop__carhop-theme__DEV/template-parts/components/cards/slider-card.php

60 lines
1.8 KiB
PHP

<?php
$postID = $args['ID'];
$isSwiperSlide = $args['isSwiperSlide'] ?? false;
$showCover = $args['showCover'] ?? false;
$cover = get_the_post_thumbnail_url($postID);
$current_post_type = get_post_type($postID);
$showTags= $args['showTags'] ?? true;
?>
<div class="slider-card <?php echo $isSwiperSlide ? 'swiper-slide' : ''; ?>">
<?php get_template_part('template-parts/components/content-meta', null, array(
'current_post_type' => $current_post_type,
'current_post_id' => $postID
)); ?>
<a href="<?php echo get_the_permalink($postID); ?>" class="slider-card__link">
<h4 class="slider-card__title"><?php echo get_the_title($postID); ?></h4>
</a>
<?php if ($showTags) : ?>
<ul class="slider-card__tags">
<?php
$terms = get_the_terms($postID, 'etiquettes');
if ($terms): ?>
<?php foreach ($terms as $term): ?>
<li class="slider-card__tag slider-tag">
<a href="<?php echo add_query_arg('etiquette', $term->slug, get_post_type_archive_link('articles')); ?>">
<?php echo esc_html($term->name); ?>
</a>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
<?php endif; ?>
<time datetime="<?php echo get_the_date('c', $postID); ?>" class="slider-card__date"><?php echo get_the_date('d F Y', $postID); ?></time>
<?php if ($showCover && isset($cover) && $cover) : ?>
<div class="slider-card__cover">
<img src="<?php echo $cover; ?>" alt="<?php echo get_the_title($postID); ?>">
</div>
<?php endif; ?>
<?php get_template_part('template-parts/components/cta--go', null, array(
'url' => get_the_permalink($postID),
'label' => 'Lire la revue',
'target' => '_self',
)); ?>
<?php
$svg_path = get_template_directory() . '/resources/img/elements/fond-biseau.svg';
if (file_exists($svg_path)) {
echo file_get_contents($svg_path);
}
?>
</div>