我有以下代码,它基本上提取了分类“类别”的术语列表。然后它会拉入该术语的每个帖子。
$terms = get_terms('categories');
foreach ($terms as $term) {
$wpq = array ('taxonomy'=>'categories','term'=>$term->slug);
$myquery = new WP_Query ($wpq);
$article_count = $myquery->post_count;
echo "<h3 class=\"term-heading\" id=\"".$term->slug."\">";
echo $term->name;
echo "</h3>";
if ($article_count) {
echo "<ul>";
while ($myquery->have_posts()) : $myquery->the_post();
echo "<li><a href=\"".get_permalink()."\">".$post->post_title."</a></li>";
endwhile;
echo "</ul>";
}
}
我的问题是我将如何将查询限制为仅从每个术语中提取 1 个帖子?
任何帮助将不胜感激,干杯丹