'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; }