【问题标题】:how to show different post of different category on different pages in wordpress?如何在wordpress的不同页面上显示不同类别的不同帖子?
【发布时间】:2015-10-28 08:06:35
【问题描述】:

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

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

谢谢

【问题讨论】:

  • 请检查我的答案。

标签: php html wordpress


【解决方案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 的文档。

【讨论】:

    【解决方案2】:

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

    http://codex.wordpress.org/Category_Templates

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-06-16
        • 2020-06-12
        • 1970-01-01
        • 2015-11-24
        • 2012-05-29
        • 2016-12-23
        相关资源
        最近更新 更多