기본적으로 분류 "카테고리"에 대한 용어 목록을 가져 오는 다음 코드가 있습니다. 그런 다음 해당 기간의 모든 게시물을 가져옵니다.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'은 사용되지 않습니다으로, 'posts_per_page'에서 'showposts'을 변경하는 것이 좋습니다 대신 – danyo
"showposts"를 사용했다. – maiorano84