FEAT Introducing getRevueAuthors function
This commit is contained in:
parent
141a2aa985
commit
ea89cd61cc
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
function getRevueAuthors($revueID)
|
||||
{
|
||||
|
||||
|
||||
$revueRelatedArticles = new WP_Query(array(
|
||||
'post_type' => '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;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user