Luoshui邀请您加入WORDPRESS技术交流QQ群:31196817 →![]()
一段以分类形式显示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 } ?>
转载请注明:有风的日子 > WordPrees > WordPress以分类形式显示文章列表
php现在好像比较少用了