From ea89cd61ccf5fc811edd7d60213756512db995d4 Mon Sep 17 00:00:00 2001 From: Nonimart Date: Thu, 12 Jun 2025 08:53:37 +0200 Subject: [PATCH] FEAT Introducing getRevueAuthors function --- includes/utilities.php | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/includes/utilities.php b/includes/utilities.php index e69de29..217d786 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -0,0 +1,49 @@ + 'articles', + 'posts_per_page' => -1, + '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 $authorID) { + $authors[] = $authorID; + } + } + return array_unique($authors); + s; +} + + +function count_user_articles($userID, $postType) +{ + $args = array( + 'post_type' => $postType, + 'meta_query' => array( + array( + 'key' => 'authors', + 'value' => '"' . $userID . '"', + 'compare' => 'LIKE', + ), + ), + ); + $query = new WP_Query($args); + return $query->found_posts; +}