This commit is contained in:
parent
17bea1ba4a
commit
4c85c58127
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
$postId = $args['postId'];
|
||||
$authors = [];
|
||||
$postId = $args['postId'] ?? get_the_ID();
|
||||
$authors = get_field('authors', $postId);
|
||||
$isArticle = is_singular('articles');
|
||||
|
||||
if ($isArticle) {
|
||||
|
|
@ -10,15 +10,27 @@ if ($isArticle) {
|
|||
}
|
||||
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(
|
||||
'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;
|
||||
?>
|
||||
|
||||
<div class="authors-last-publications">
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user