carhop__dynamiques-theme__P.../template-parts/authors/authors-last-publications.php
2025-06-25 12:28:43 +02:00

39 lines
967 B
PHP

<?php
$postId = $args['postId'];
$authors = [];
$isArticle = is_singular('articles');
if ($isArticle) {
$authors = get_field('authors', $postId);
} else {
$authors = getRevueAuthors($postId);
}
if (empty($authors)) return;
$authorsLastPosts = get_posts(array(
'post_type' => $isArticle ? 'articles' : 'revues',
'author' => $authors,
'posts_per_page' => 6,
'orderby' => 'date',
'order' => 'DESC',
));
if (empty($authorsLastPosts)) return;
?>
<div class="authors-last-publications">
<?php if (count($authors) <= 1) : ?>
<h3 class="title-small">Ses dernières publications</h3>
<?php else : ?>
<h3 class="title-small">Leurs dernières publications</h3>
<?php endif; ?>
<?php foreach ($authorsLastPosts as $post) : ?>
<?php get_template_part('template-parts/articles/card-article', null, array(
'ID' => $post->ID,
'showAuthors' => true,
)); ?>
<?php endforeach; ?>
</div>
<?php wp_reset_postdata(); ?>