wordpress调用指定分类文章代码


wordpress调用指定分类文章代码:

<ul>
<?php query_posts('cat=1&showposts=5'); ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; wp_reset_query(); ?>
</ul>

cat是要调用的分类ID,showposts是需要显示的文章数量。

如果想从第二篇开始调用可以加一个参数&offset=1,第三篇开始调用就用&offset=2,以此类推。

标签:

文章发布时间:2020-05-22