【问题标题】:category.php template is not working instead index.php works?category.php 模板不工作,而不是 index.php 工作?
【发布时间】:2020-02-15 02:49:08
【问题描述】:

在 WordPress 帖子中,模板 category.php 不起作用,而 index.php 用于存档和类别页面。所以我无法正确获取 index.php 模板文件中的类别。

get_the_category();和 get_query_var() 在此页面中无效。

我只想要一个使用 category.phpindex.php 的 WordPress 帖子的类别页面。 有人可以帮忙吗?

【问题讨论】:

  • 你的header.phpwp_head()的功能吗?
  • 是的,它有 wp_head() 函数。

标签: php wordpress categories posts


【解决方案1】:

也许不是您正在寻找的答案,但在我的情况下,使用 archive.php 的解决方案就足够了。

将为作者和其他存档加载同一页面。但对我来说,我只是使用类别。

更新:

也可以使用 categories.php 代替 category.php(或 archive.php)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-27
    • 1970-01-01
    相关资源
    最近更新 更多