WordPress载入页面内容时加载模板的机制(图)

当wordpress载入页面/内容时,它会查找你的主题文件夹并根据命名载入正确的模板页面,Wordpress调用不用的页面/内容,wordpress的查找顺序如下:

  • 404
    1. 404.php
    2. index.php
  • Search
    1. search.php
    2. index.php
  • Tax
    1. taxonomy-{tax}-{term}.php
    2. taxonomy-{tax}.php
    3. taxonomy.php
    4. archive.php
    5. index.php
  • Home
    1. home.php
    2. index.php
  • Attachment
    1. mime.php
    2. type.php
    3. mime_type.php
    4. attachment.php
    5. single.php
    6. index.php
  • Single
    1. single-{post-type}.php
    2. single.php
    3. index.php
  • Page
    1. custom_template.php
    2. page-{slug}.php
    3. page-{id}.php
    4. page.php
    5. index.php
  • Category
    1. category-{slug}.php
    2. category-{id}.php
    3. category.php
    4. archive.php
    5. index.php
  • Tag
    1. tag-{slug}.php
    2. tag-{id}.php
    3. tag.php
    4. archive.php
    5. index.php
  • Author
    1. author-{author-nicename}.php
    2. author-{author-id}.php
    3. author.php
    4. archive.php
    5. index.php
  • Date
    1. date.php
    2. archive.php
    3. index.php
  • Archive
    1. archive.php
    2. index.php

WordPress页面/内容函数对应的模板,WordPress加载模板的机制如下图:

人吐槽 人点赞

猜你喜欢

发表评论

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:WordPress载入页面内容时加载模板的机制(图)