【问题标题】:how can i create archives for custom post type如何为自定义帖子类型创建档案
【发布时间】:2014-10-10 16:00:00
【问题描述】:

WordPress 框架允许为您的每个自定义帖子类型构建不同的存档模板,例如:

archive-event.php
taxonomy-event_category.php

是否可以通过执行以下操作为自定义帖子类型创建作者和日期存档:

author-event.php
date-event.php

如果这是不可能的,谁能告诉我如何才能实现这一目标?

【问题讨论】:

    标签: wordpress custom-post-type


    【解决方案1】:

    我认为这些链接将有助于回答您的问题并帮助您入门: http://codex.wordpress.org/Template_Hierarchy http://codex.wordpress.org/Category_Templates

    它的要点是,您实际上可以创建一个author-event.php,但不会检查date-event.php,因为模板层次结构规定它使用date.phparchive.phpindex.php

    一种解决方案是使用条件标签,例如is_author()is_date()。如果这样做,请记住,您必须有一个通用的archive.php,并通过使用条件标签来决定您真正想要使用的模板。

    【讨论】:

      猜你喜欢
      • 2020-06-06
      • 2011-06-04
      • 1970-01-01
      • 1970-01-01
      • 2012-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多