WordPress中有很多不同类型的内容,除了默认的Post Types之外,您还可以创建自定义分类目录,所有分类目录存储在同一个地方,在wp_posts数据库表。
[dt_highlight color=”” text_color=”” bg_color=””][/dt_highlight] 默认分类目录
有五种默认的Post Types可供用户使用或或者WordPress安装内部使用:
- 文章
- 页面
- 附件
- 修订
- 导航菜单
[dt_highlight color=”” text_color=”” bg_color=””][/dt_highlight] 主页
- home.php
- index.php
备注:如果存在home.php,则使用home.php作为首页模板,如果home.php未找到,则使用index.php作为首页模板;
[dt_highlight color=”” text_color=”” bg_color=””][/dt_highlight] 文章
- single-{post_type}.php
- single.php
- index.php
备注: 如果文章类型是视频,WordPress则查找single-videos.php
[dt_highlight color=”” text_color=”” bg_color=””][/dt_highlight] 页面
- 自定义模板
- page-{slug}.php
- page-{id}.php
- page.php
- index.php
[dt_highlight color=”” text_color=”” bg_color=””][/dt_highlight] 分类
- category-{slug}.php
- category-{id}.php
- category.php
- archive.php
- index.php
[dt_highlight color=”” text_color=”” bg_color=””][/dt_highlight] 标签
- tag-{slug}.php
- tag-{id}.php
- archive.php
- index.php
[dt_highlight color=”” text_color=”” bg_color=””][/dt_highlight] 作者
- author-{nicename}.php
- author-{id}.php
- author.php
- archive.php
- index.php
[dt_highlight color=”” text_color=”” bg_color=””][/dt_highlight] 日期
- date.php
- archive.php
- index.php
[dt_highlight color=”” text_color=”” bg_color=””][/dt_highlight] 附件
MIME_type.php
attachment.php
single-attachment.php
single.php
index.php
备注:使用自定义分类目录,可以创建自己的分类目录。但不建议您将此功能放在主题中。这种类型的功能应该放在插件中。如果更改主题,存储在自定义分类目录中的内容将不会消失。
虽然您通常不会在主题中开发自定义分类目录,但您可能需要编写插件创建自定义分类目录。以下模板可以显示自定义分类目录:
single-{post-type}.php
archive-{post-type}.php
search.php
index.php
此外,主题开发人员可以在任何模板文件中显示自定义分类目录。