【问题标题】:specific category address show same thing that show in homepage特定类别地址显示与主页显示相同的内容
【发布时间】:2013-05-14 08:19:34
【问题描述】:

我有一个包含多个类别的博客,每个类别都有一些帖子。在 index.php 中使用 WP_Query($args) 我在主页上显示帖子。没关系。

$args = array(
    'cat' => -22,
);
$recent = new WP_Query($args); while($recent->have_posts()) : $recent->the_post();?>

但我的问题是 *http://www.example.com/category/cat1/*contents 等类别链接与主页内容相同。

我正在寻找问题。 注意:我想删除索引和类别中的 cat = 22

【问题讨论】:

    标签: wordpress categories


    【解决方案1】:

    你是说你去*http://www.example.com/category/cat1/之类的分类页面和你去首页的时候是一样的吗?

    如果是这样,您的主题中缺少category.php 模板。

    来自Codex 的关于模板层次结构的示例:

    如果您的博客位于 http://example.com/blog/ 并且访问者点击 链接到类别页面,例如 http://example.com/blog/category/your-cat/: 这里是进度 WordPress 如何使用模板层次结构来查找和生成 正确的文件。

    WordPress 在当前主题目录中查找模板文件 与类别 ID 匹配。

    If the category's ID is 4, WordPress looks for a template file named category-4.php.
    If it is missing, WordPress next looks for a generic category template file, category.php.
    If this file does not exist either, WordPress looks for a generic archive template, archive.php.
    If it is missing as well, WordPress falls back on the main Theme template file, index.php.
    

    您可以使用 Wordpress 中默认的 Twenty Twelwe 主题中的代码来创建类别模板。 只需转到 Dashoard > Appearance > Editor,选择该主题并从 category.php 复制代码

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-06
    • 1970-01-01
    • 1970-01-01
    • 2016-10-25
    • 1970-01-01
    • 2010-12-22
    相关资源
    最近更新 更多