FEATURE Adapting card to handle post thumbnail
This commit is contained in:
parent
332d905a32
commit
1be5cf1d1b
|
|
@ -1,14 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
$ID = $args['ID'] ?? null;
|
$ID = $args['ID'] ?? null;
|
||||||
$current_post_type = $args['current_post_type'] ?? get_post_type();
|
$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);
|
$title = get_the_title($ID);
|
||||||
$showExcerpt = $args['show_excerpt'] ?? false;
|
$showExcerpt = $args['show_excerpt'] ?? false;
|
||||||
|
|
||||||
$excerpt = get_the_excerpt($ID);
|
$excerpt = get_the_excerpt($ID);
|
||||||
$link = get_the_permalink($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);
|
$date = get_the_date('F Y', $ID);
|
||||||
|
|
||||||
$authors = get_field('authors', $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; ?>">
|
<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) : ?>
|
||||||
<?php get_template_part('template-parts/components/content-meta', null, array(
|
<div class="post-card__thumbnail">
|
||||||
'current_post_type' => $current_post_type,
|
<img src="<?php echo $thumbnail_url; ?>" alt="<?php echo $title; ?>">
|
||||||
'current_post_id' => $ID
|
</div>
|
||||||
)); ?>
|
<?php endif; ?>
|
||||||
<div class="card__inner">
|
<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">
|
<div class="card__content">
|
||||||
<h3 class="card__title"><?php echo $title; ?></h3>
|
<h3 class="card__title"><?php echo $title; ?></h3>
|
||||||
<?php if ($showExcerpt) : ?>
|
<?php if ($showExcerpt) : ?>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user