以分类形式获取WordPress文章列表

很多的Wordpress文章归档都是以日期形式获取的文章列表,在文章归档页面也是以日期进行组织的。在Wordpress定制开发时,可能也会有需要以分类形式获取Wordpress文章列表。

你可以通过以下代码获取以分类形式显示的WordPress文章列表,从而实现在单页上显示全部分类文章,做成一个以分类进行组织的文章归档单页。文章源自堕落的鱼-https://www.duoluodeyu.com/2282.html

  1. <?php
  2.     $cats = get_categories();
  3.     foreach ( $cats as $cat ) {
  4.     query_posts( 'showposts=10&cat=' . $cat->cat_ID );
  5. ?>
  6.     <h3><?php echo $cat->cat_name; ?></h3>
  7.     <ul class="sitemap-list">
  8.         <?php while ( have_posts() ) { the_post(); ?>
  9.         <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
  10.         <?php } wp_reset_query(); ?>
  11.     </ul>
  12. <?php } ?>
文章源自堕落的鱼-https://www.duoluodeyu.com/2282.html文章源自堕落的鱼-https://www.duoluodeyu.com/2282.html
 
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证