diff --git a/template-parts/authors/authors-last-publications.php b/template-parts/authors/authors-last-publications.php index 3a71eae..5fb5666 100644 --- a/template-parts/authors/authors-last-publications.php +++ b/template-parts/authors/authors-last-publications.php @@ -1,6 +1,6 @@ '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( 'post_type' => $isArticle ? 'articles' : 'revues', - 'author' => $authors, 'posts_per_page' => 6, 'orderby' => 'date', 'order' => 'DESC', + 'meta_query' => $meta_query, )); -if (empty($authorsLastPosts)) return; +if (empty($authorsLastPosts) || count($authorsLastPosts) < 2) return; ?>