最新下载
热门教程
- 1
 - 2
 - 3
 - 4
 - 5
 - 6
 - 7
 - 8
 - 9
 - 10
 
wordpress开源博客主题开发文件结构讲解
时间:2022-06-25 18:52:19 编辑:袖梨 来源:一聚教程网
下面是WordPress主题文件层次结构,它会告诉你:当WordPress显示特定的页面类型时,会使用哪个模板文件呢?只有了解了以下主题层次结构,你才能知道你的WordPress主题到底需要写哪些文件。
怎么看下面的文件层次结构?
以主页为例,下面有2个文件home.php和index.php,WordPress程序会从你的主题文件夹中依次查找这两个文件:
        如果找到home.php,则使用home.php作为博客首页模板,即使你的主题文件夹中有index.php;
        如果home.php未找到,则使用index.php作为首页模板;
        如果home.php和index.php都找不到,你的主题将不会被WordPress识别,等于废物。
主页
        home.php
        index.php
文章页:
        single-{post_type}.php – 如果文章类型是videos(即视频),WordPress就会去查找single-videos.php(WordPress 3.0及以上版本支持)
        single.php
        index.php
页面
        自定义模板 – 在WordPress后台创建页面的地方,右侧边栏可以选择页面的自定义模板
        page-{slug}.php – 如果页面的缩略名是news,WordPress将会查找 page-news.php(WordPress 2.9及以上版本支持)
        page-{id}.php – 如果页面ID是6,WordPress将会查找page-6.php
        page.php
        index.php
分类
        category-{slug}.php – 如果分类的缩略名为news,WordPress将会查找category-news.php(WordPress 2.9及以上版本支持)
        category-{id}.php -如果分类ID为6,WordPress将会查找category-6.php
        category.php
        archive.php
        index.php
标签
        tag-{slug}.php – 如果标签缩略名为sometag,WordPress将会查找tag-sometag.php
        tag-{id}.php – 如果标签ID为6,WordPress将会查找tag-6.php(WordPress 2.9及以上版本支持)
        tag.php
        archive.php
        index.php
作者
        author-{nicename}.php – 如果作者的昵称为rami,WordPress将会查找author-rami.php(WordPress 3.0及以上版本支持)
        author-{id}.php – 如果作者ID为6,WordPress将会查找author-6.php(WordPress 3.0及以上版本支持)
        author.php
        archive.php
        index.php
日期页面
        date.php
        archive.php
        index.php
搜索结果
        search.php
        index.php
404 (未找到)页面
        404.php
        index.php
附件页面
        MIME_type.php – 可以是任何MIME类型 (image.php, video.php, audio.php, application.php 或者其他).
        attachment.php
        single.php
        index.php
详细说明,请看WordPress官方文档:http://codex.wor***dpress.org/Template_Hierarchy
相关文章
- 炉石传说标准小行星萨卡组推荐分享 11-04
 - 炉石传说基尔加丹轮盘术卡组推荐分享 11-04
 - 炉石传说宇宙彩虹DK高胜率卡组推荐分享 11-04
 - 炉石传说深暗领域德鲁伊卡组推荐分享 11-04
 - 过山车之星2景观评分提升方法分享 11-04
 - 过山车之星2景点声望提升方法分享 11-04