我有以下代碼,它基本上爲分類「類別」提供了一個條目列表。然後它會抽出每個職位的任期。限制帖子從get_terms中提取
$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職位?
任何幫助將不勝感激,乾杯丹
感謝,POST_COUNT didnt相當的工作,所以我用 「showposts」,而不是 – danyo
考慮更改 'showposts' 到 'posts_per_page',爲 'showposts' 被棄用。 – maiorano84