Updated: I have 50 categories and i wants to show each 5 category on one page and next 5 on next page and next 5 on next page. and so on. with pagination.
我在WordPress网站上有50个类别。我想在每一页上显示五个类别,用10篇文章分页。我已经尝试过了,但分页并没有产生效果。
<?php
// get all the categories from the database
$cats = get_categories();
// loop through the categries
foreach ($cats as $cat) {
// setup the cateogory ID
$cat_id= $cat->term_id;
// Make a header for the cateogry
?>
<div class="cats-by-2">
<div class="cat-posts-left">
<h2 class="feat-title"><span><a href=""><?php echo \'<h2>\'.$cat->name.\'</h2>\'; ?></a></span></h2>
<div class="posts-by-3">
<?php
// create a custom wordpress query
query_posts("cat=$cat_id");
$count = 1;
if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post-wrap<?php if ($count%3 == 0) { ?> right<?php } ?>">
<div <?php post_class(); ?> id="post-main-<?php the_ID(); ?>">
<div class="entry clearfix">
<h2 class="post-title"><a href="<?php the_permalink() ?>" rel="<?php _e("bookmark", "solostream"); ?>" title="<?php _e("Permanent Link to", "solostream"); ?> <?php the_title(); ?>"><?php the_title(); ?></a></h2>
</div>
<?php include (TEMPLATEPATH . "/postinfo.php"); ?>
</div>
</div>
<?php if ( $count%3 == 0 ) { ?>
<div class="post-clear"></div>
<?php } ?>
<?php $count = $count + 1 ?>
<?php endwhile; endif;
// done our wordpress loop. Will start again for each category ?>
</div></div>
</div>
<?php } // done the foreach statement ?>