
WordPress循环获取指定分类目录文章列表
在WordPress开发中经常会需要用到在某个页面展示某个分类目录的文章,这样时候就会需要用到 WordPress循环 获取指定分类目录文章列表的语句:
1 2 3 | <?php query_posts('cat=20&posts_per_page=4'); while(have_posts()): the_post(); ?> <li><a href="<?php the_permalink(); ?>" target="_blank"><?php the_title();?></a></li> <?php endwhile; wp_reset_query(); ?> |
注意:其中cat=20代表分类ID,posts_per_page=4代表显示几条记录。
点击【分享给朋友】生成专属代理二维码,享受推广消费现金奖励!