<?php
$categories = get_categories();
foreach ($categories as $cat) :?>
<div class="category_box">
<?php
// get most recent post in cat
query_posts('posts_per_page=1&cat='.$cat->cat_ID);
if (have_posts()) : while (have_posts()) : the_post();
?>
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?> </a></h2>
<?php the_content('continue reading...'); ?>
<?php
endwhile;
endif;
wp_reset_query();
// get 4 most recent posts in cat offset by 1
query_posts('posts_per_page=4&offset=1&cat='.$cat->cat_ID);
if(have_posts()) :?>
<ul class="more-stories">
<?php
while (have_posts()) :the_post();
?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
<?php endif; wp_reset_query();?>
</div><!--category_box-->
<?php endforeach; ?>
<?php $categories = get_categories();
foreach ($categories as $cat) : ?>
<?php // get most recent post in cat
query_posts('posts_per_page=5&cat='.$cat->cat_ID);
if (have_posts()) : while(have_posts()) : the_post();
?>
<h2>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</h2>
<?php endwhile; ?>
<?php endif;
wp_reset_query();
?>
<?php endforeach; ?>
WordPress类别文件循环打印
最新推荐文章于 2025-08-12 21:54:14 发布