我有 50 个类别,每个类别都有 100 个帖子。我有一个页面模板,在此页面上我想显示包含 5-5 个帖子的类别,但在分页中。我已经使用了下面的代码,但没有任何分页,也没有任何帖子发现只有类别名称。
$args = array(
'type' => 'post',
'child_of' => 0,
'parent' => '',
'orderby' => 'ID',
'order' => 'ASC',
'hide_empty' => 1,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => '',
'taxonomy' => 'category',
'pad_counts' => false
);
$categories = get_categories($args);
foreach($categories as $category){ $catId[] = $category->term_id; }
$catId_comma_separated = implode(",", $catId);
$myposts = get_posts(array('numberposts' => 5, 'offset' => 0, 'cat' => $catId_comma_separated, 'post_status'=>'publish', 'order'=>'ASC' ));
query_posts( "cat = $catId_comma_separated");
while ( have_posts() ) : the_post();
echo '<li>';
the_title();
echo '</li>';
endwhile;
// Reset Query
wp_reset_query();
custom_pagination();