WordPress以分类形式显示文章列表-WordPress主题教程
3周前 (02-10)
一段以分类形式显示WordPress文章列表代码,修改其中的数字10可以设定显示的篇数,可用于在单页面上显示全部分类文章。
<?php
$cats = get_categories();
foreach ( $cats as $cat ) {
query_posts( 'showposts=10&cat=' . $cat->cat_ID );
?>
<h3><?php echo $cat->cat_name; ?></h3>
<ul class="sitemap-list">
<?php while ( have_posts() ) { the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php } wp_reset_query(); ?>
</ul>
<?php } ?>