FIX latest articles
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Nonimart 2025-10-06 11:36:12 +02:00
parent 17bea1ba4a
commit 4c85c58127

View File

@ -1,6 +1,6 @@
<?php <?php
$postId = $args['postId']; $postId = $args['postId'] ?? get_the_ID();
$authors = []; $authors = get_field('authors', $postId);
$isArticle = is_singular('articles'); $isArticle = is_singular('articles');
if ($isArticle) { if ($isArticle) {
@ -10,15 +10,27 @@ if ($isArticle) {
} }
if (empty($authors)) return; if (empty($authors)) return;
// Construire une meta_query avec OR pour chaque auteur
$meta_query = array('relation' => 'OR');
foreach ($authors as $author_id) {
$meta_query[] = array(
'key' => 'authors',
'value' => '"' . $author_id . '"', // Recherche la valeur sérialisée
'compare' => 'LIKE'
);
}
$authorsLastPosts = get_posts(array( $authorsLastPosts = get_posts(array(
'post_type' => $isArticle ? 'articles' : 'revues', 'post_type' => $isArticle ? 'articles' : 'revues',
'author' => $authors,
'posts_per_page' => 6, 'posts_per_page' => 6,
'orderby' => 'date', 'orderby' => 'date',
'order' => 'DESC', 'order' => 'DESC',
'meta_query' => $meta_query,
)); ));
if (empty($authorsLastPosts)) return; if (empty($authorsLastPosts) || count($authorsLastPosts) < 2) return;
?> ?>
<div class="authors-last-publications"> <div class="authors-last-publications">