【发布时间】:2016-05-03 09:57:08
【问题描述】:
如何将此类别列表放在分页中,因为目前我有一个代码可以显示所有类别列表,包括按类别发布的内容。 问题是如果类别列表超过10,如何使其分页。
$cats = get_categories("exclude=1,5,15");
foreach ($cats as $cat) {
// setup the cateogory ID
$cat_id= $cat->term_id;
$cat_child =$cat -> category_parent;
// Make a header for the cateogry
echo "<div class='anchor2' id='cat_".$cat_id. "'></div>";
echo "<div id='". $cat_child ."'class='cat_id".$cat_id." cat-cont large-6 medium-6 columns pad25px'>";
echo "<h5 class='title-post cat_id_" . $cat_id ."' >".$cat->name."</h5>";
echo "<a href='dev/all/#cat_".$cat_id."' class='see-more' target='_blank'>See more >></a>";
// create a custom wordpress query
query_posts("cat=$cat_id&posts_per_page=5&depth=1");
// start the wordpress loop!
if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php // create our link now that the post is setup ?>
<?php get_template_part( 'parts/loop', 'archive-grid' ); ?>
<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'parts/content', 'missing' ); ?>
<?php endif; // done our wordpress loop. Will start again for each category ?>
<?php echo "</div>";}// done the foreach statement ?>
【问题讨论】:
标签: php wordpress pagination categories