正如我对WordPress所知,我们必须找到实现这一目标的方法。
First: 你必须检索作者写的所有帖子,然后才能获取分配给这些帖子的类别。将它们唯一地存储在一个数组中。
$args = array(\'author\' => $author->ID, \'posts_per_page\' => -1, \'fields\' => \'ids\');
$authorArticles = get_posts($args);
$postList = array();
foreach($authorArticles as $key => $article){
if(!in_array($article, $postList)){
$postList[$key] = $article;
}
}
$termsList = array();
$siteURL = site_url(\'/category/\');
foreach($postList as $article){
$terms = get_the_terms($article, \'category\');
foreach($terms as $term){
if(!isset($termsList[$term->term_id])){
$termsList[$term->term_id] = [\'term_id\' => $term->term_id, \'term_url\' => $siteURL.$term->slug];
}
}
}
echo \'<pre>\', print_r($termsList), \'</pre>\';
Second: 正如@Jacob所建议的,您必须使用SQL来检索类别列表。
顺致敬意,