33 lines
1.2 KiB
PHP
33 lines
1.2 KiB
PHP
<?php
|
|
$relatedPostId = $attributes['relatedPostId'] ?? null;
|
|
$postType = get_post_type_object(get_post_type($relatedPostId));
|
|
|
|
$relatedPost = get_post($relatedPostId) ?? null;
|
|
$relatedPostUrl = get_permalink($relatedPostId) ?? null;
|
|
$cover = get_field('cover', $relatedPostId) ?? null;
|
|
$target = $postType->name === 'fiches-infos' ? "_blank" : "_self";
|
|
$thematique = get_the_terms($relatedPostId, 'thematiques')[0];
|
|
$mainThematique = getMainThematique($thematique);
|
|
$thematiqueColorSlug = $mainThematique->slug;
|
|
$thematique_icon = get_field('taxonomy_pictures', 'thematiques' . '_' . $mainThematique->term_id)['icon'];
|
|
// echo '<pre>';
|
|
// print_r($postType);
|
|
// echo '</pre>';
|
|
|
|
|
|
?>
|
|
<a class="post-card" href="<?php echo $relatedPostUrl ?>" target="<?php echo $target ?>">
|
|
|
|
<img class="post-card__cover" src="<?php echo $thematique_icon['url'] ?>" alt="">
|
|
|
|
<div class="post-card__details">
|
|
<div class="post-card__tags">
|
|
|
|
<?php if ($mainThematique) : ?>
|
|
<div class="tag thematique-tag thematique-tag--<?php echo $mainThematique->slug ?>"><?php echo $mainThematique->name ?></div>
|
|
<?php endif; ?>
|
|
<div class="tag post-type-tag"><?php echo $postType->label ?></div>
|
|
</div>
|
|
<h2 class="post-card__title"><?php echo $relatedPost->post_title ?></h2>
|
|
</div>
|
|
</a>
|