From f94abb14b7b0eebe63b9be8d8100c100f3a0282a Mon Sep 17 00:00:00 2001 From: Nonimart Date: Thu, 12 Jun 2025 08:54:50 +0200 Subject: [PATCH] FEAT Ajout de la fonction renderRevueAuthorsGrid pour afficher les auteurs d'une revue --- includes/renderPostsDatas.php | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 includes/renderPostsDatas.php diff --git a/includes/renderPostsDatas.php b/includes/renderPostsDatas.php new file mode 100644 index 0000000..63a2103 --- /dev/null +++ b/includes/renderPostsDatas.php @@ -0,0 +1,47 @@ + 'articles', + 'posts_per_page' => 3, + 'orderby' => 'date', + 'order' => 'DESC', + 'post_status' => 'publish', + 'meta_query' => array( + array( + 'key' => 'related_revue', + 'value' => $revueID, + 'compare' => '=', + ), + ), + )); + $authors = array(); + foreach ($revueRelatedArticles->posts as $article) { + $currentArticleAuthors = get_field('authors', $article->ID); + if (empty($currentArticleAuthors) || !is_array($currentArticleAuthors)) continue; + + foreach ($currentArticleAuthors as $author) { + $authors[] = $author; + } + } + + $authors = array_unique($authors); + + + ob_start(); + foreach ($authors as $key => $author) { + get_template_part( + 'template-parts/authors/card-author', + null, + array( + 'ID' => $author->ID, + ) + ); + } + $grid_template = ob_get_clean(); + + + return $grid_template; +}