wordpress显示指定分类下文章列表的代码
wordpress搭建的博客,想要显示某个分类目录下的所有文章,下面是代码:
<table>
<?php query_posts("showposts=5&cat=10")?> //根据需要修改文章数量和分类目录的ID
<?php while (have_posts()) : the_post(); ?>
<tr>
<td><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></td>
<td><?php the_time('Y-m-d'); ?></td>
</tr>
<?php endwhile; ?>
</table>
只需要根据需要修改要显示的文章数量和分类目录的ID就可以了。
如何获取分类目录的ID?
切换到后台“分类目录”页面,将鼠标移动到你希望获得ID的“分类目录”下,状态栏就会显示器url,其中tag_ID后跟着的就是其ID。