carhop__carhop-theme__DEV/template-parts/components/post-card.php

44 lines
1.3 KiB
PHP

<?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);
$excerpt = get_the_excerpt($ID);
$link = get_the_permalink($ID);
$image = get_the_post_thumbnail_url($ID);
$date = get_the_date('F Y', $ID);
$authors = get_field('authors', $ID);
$numerotation = get_post_meta($ID, 'post_numerotation', true);
?>
<div class="post-card post-card--<?php echo $current_post_type; ?> card">
<?php get_template_part('template-parts/components/content-meta', null, array(
'current_post_type' => $current_post_type,
'current_post_id' => $ID
)); ?>
<div class="card__inner">
<div class="card__content">
<h3 class="card__title"><?php echo $title; ?></h3>
<div class="card__excerpt"><?php echo $excerpt; ?></div>
</div>
<div class="card__details">
<time datetime="<?php echo $date; ?>" class="card__details-date date"><?php echo $date; ?></time>
<?php if ($authors) : ?>
<ul class="post-card__authors">
<?php foreach ($authors as $author) : ?>
<li class="author"><?php echo $author->post_title; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
</div>