如何在wordpress的不同页面上显示不同类别的不同帖子?

时间:2013-11-15 13:01:04

标签: php html wordpress

我正在使用wordpress主题,我想根据类别在不同页面上显示帖子。

例如页面名称是“博客”,帖子类别是postBlog,你能告诉我如何根据类别使用帖子。

谢谢

3 个答案:

答案 0 :(得分:1)

使用WordPress Category Template可以实现您想要做什么。

来自食典委:

For instance, when a viewer clicks on a link to one of the Categories on your site, he or she is taken to a page listing the Posts from that particular Category in chronological order, from newest Posts at the top to oldest at the bottom.

您可以在主题中创建一个名为category.php的文件,在其中放置loop,然后WordPress会自动为您执行此操作。

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

然后用页面填满你的需求。您可以查看The Loop here in this link的文档。

答案 1 :(得分:0)

在主题目录中创建模板category-catname.phpcategory-catID.php

请参阅http://codex.wordpress.org/Category_Templates

答案 2 :(得分:0)

我认为人们在尝试使用Pages时会感到困惑,因为他们实际上更善于使用类别。如果您希望博客帖子显示在不同的网址或“页面”上。那么你所要做的就是设置你的类别并将这些类别放入你的菜单中。然后,当您发布时,请确保选择您希望该帖子显示的类别。你根本不必使用页面。页面更适合静态内容。

祝你好运,我希望这会有所帮助。