根据帖子类型显示不同的模板
2 个回答
- 投票数
-
- 2010-10-06
尝试
single-events.php
.有关完整的模板方案,请参见Codex中的模板层次结构.
Try
single-events.php
.See Template Hierarchy in Codex for full scheme of templates.
-
很有魅力,我只是习惯了WordPress的工作方式,老实说我不知道它这么灵活!Works a charm, I'm only getting used to how WordPress works, i honestly didn't know it was this flexible!
- 0
- 2010-10-06
- dotty
-
是的,模板是非常灵活的系统.请注意,某些框架(例如Hybrid)会应用自己的模板层次结构,默认设置并非一成不变.Yep, templates are extremely flexible system. Just be aware that some frameworks (like Hybrid) apply their own template hierarchy, defaults are not set in stone.
- 0
- 2010-10-06
- Rarst
-
- 2011-01-30
这就是为什么使用自定义模板文件(如page- {post_type} .php和single- {post_type} .php)非常方便的原因.在3,1中,也归档-{post_type} .php.
是的,您只是使用类似的自定义模板为您的帖子类型创建模板文件,而不是在文件顶部的注释中添加模板名称的方式.这样很烂,而且我从没使用过,并且创建了诸如maddness之类的帖子类型.
This is why using the custom template files that you can use like page-{post_type}.php and single-{post_type}.php are extremely handy. And in 3,1, archive-{post_type}.php too.
So yea, you just create a template file for your post types, using the custom templates like that instead of the way where you put the template name in a comment at the top of the file. That way sucks, and I never ever use it, and I create post types like maddness.
-
我在法典中读到过" single- {post_type} .php"和" archive- {post_type} .php".找不到`page- {post_type} .php`的参考资料您确定吗?你可以分享一些参考吗?I read about `single-{post_type}.php` and `archive-{post_type}.php` in codex. Couldn't find a reference for `page-{post_type}.php` Are you sure about this? Can you share some reference?
- 0
- 2011-11-04
- a_fan
-
它是页面模板的一部分.在此处阅读有关模板层次结构的信息:http://codex.wordpress.org/Template_HierarchyIt's part of page templates. Read about the template hierarchy here: http://codex.wordpress.org/Template_Hierarchy
- 0
- 2011-11-15
- jaredwilli
对,我有一个自定义的帖子类型"事件",但是这基本上是帖子类型,因此它继承了post.php模板页面.
如果内容类型是"事件",是否仍然可以使用其他模板(即events.php)?