Heim > php教程 > php手册 > Hauptteil

WordPress主题模板层次和常用模板函数

WBOY
Freigeben: 2016-06-21 08:49:38
Original
1223 Leute haben es durchsucht

WordPress 是目前世界上使用最广泛的博客系统,是一款开源的PHP软件。因为使用者众多,所以WordPress社区非常活跃,有丰富的插件模板资源。使用WordPress可以快速搭建独立的博客网站。很多知名科技博客也是WordPress搭建的,例如:雷锋网、钛媒体等。下面PHP站为WordPress主题开发者整理了一下制作WordPress主题的必备知识。
WordPress主题模板层次
首页:

  1. home.php
  2. index.php


文章页:

  1. single-{post_type}.php – 如果文章类型是videos(即视频),WordPress就会去查找single-videos.php(WordPress 3.0及以上版本支持)
  2. single.php
  3. index.php


页面:

  1. 自定义模板 – 在WordPress后台创建页面的地方,右侧边栏可以选择页面的自定义模板
  2. page-{slug}.php – 如果页面的缩略名是news,WordPress将会查找 page-news.php(WordPress 2.9及以上版本支持)
  3. page-{id}.php – 如果页面ID是6,WordPress将会查找page-6.php
  4. page.php
  5. index.php


分类:

  1. category-{slug}.php – 如果分类的缩略名为news,WordPress将会查找category-news.php(WordPress 2.9及以上版本支持)
  2. category-{id}.php -如果分类ID为6,WordPress将会查找category-6.php
  3. category.php
  4. archive.php
  5. index.php


标签

  1. tag-{slug}.php – 如果标签缩略名为sometag,WordPress将会查找tag-sometag.php
  2. tag-{id}.php – 如果标签ID为6,WordPress将会查找tag-6.php(WordPress 2.9及以上版本支持)
  3. tag.php
  4. archive.php
  5. index.php


作者:

  1. author-{nicename}.php – 如果作者的昵称为rami,WordPress将会查找author-rami.php(WordPress 3.0及以上版本支持)
  2. author-{id}.php – 如果作者ID为6,WordPress将会查找author-6.php(WordPress 3.0及以上版本支持)
  3. author.php
  4. archive.php
  5. index.php


日期页面:

  1. date.php
  2. archive.php
  3. index.php


搜索结果:

  1. search.php
  2. index.php


404 (未找到)页面

  1. 404.php
  2. index.php


附件页面:

  1. MIME_type.php – 可以是任何MIME类型 (image.php, video.php, audio.php, application.php 或者其他).
  2. attachment.php
  3. single.php
  4. index.php


WordPress主题 – 判断Tag
is_home() : 是否为主页
is_single()  : 是否为内容页(Post)
is_page()  : 是否为内容页(Page)
is_category()  : 是否为Category/Archive页
is_tag()  : 是否为Tag存档页
is_date()  : 是否为指定日期存档页
is_year()  : 是否为指定年份存档页
is_month()  : 是否为指定月份存档页
is_day()  : 是否为指定日存档页
is_time()  : 是否为指定时间存档页
is_archive()  : 是否为存档页
is_search()  : 是否为搜索结果页
is_404()  : 是否为 “HTTP 404: Not Found” 错误页
is_paged()  : 主页/Category/Archive页是否以多页显示
判断Tag在WordPress主题里常用于侧边栏(sidebar.php)模板文件
WordPress主题 – Header 常用PHP函数
  : 博客名称(Title)
  : CSS文件路径
  : PingBack Url
  : 模板文件路径
  : WordPress版本
  : Atom Url
  : RSS 2.o Url
  : 博客 Url
  : 博客网页Html类型
  : 博客网页编码
  : 博客描述
  : 特定内容页(Post/Page)的标题
WordPress主题 – 模板常用的PHP函数
  : 调用Header模板
  : 调用Sidebar模板
  : 调用Footer模板
  : 显示内容(Post/Page)
  : 检查是否存在Post/Page
  : 如果存在Post/Page则予以显示
  : While 结束
  : If 结束
  : 显示时间,时间格式由“字符串”参数决定,具体参考PHP手册
  : 正文中的留言链接。如果使用 comments_popup_script() ,则留言会在新窗口中打开,反之,则在当前窗口打开
  : 内容页(Post/Page)标题
  : 内容页(Post/Page) Url
  : 特定内容页(Post/Page)所属Category
  : 作者
  : 特定内容页(Post/Page) ID
  : 如果用户已登录并具有权限,显示编辑链接
  : 显示Blogroll中的链接
  : 调用留言/回复模板
  : 显示Page列表
  : 显示Categories列表
  : 下一篇文章链接
  : 上一篇文章链接
  : 日历
  : 显示内容存档
: 导航,显示上一篇/下一篇文章链接
: 嵌入其他文件,可为定制的模板或其他类型文件
WordPress主题 – 与模板相关的其他函数
: 输出相应信息
: 显示注册链接
: 显示登录/注销链接
: 将当前内容分页
: 将当前内容截断,以不在主页/目录页显示全部内容
: 网页加载时间(秒)
: 网页加载查询量
转载请注明出处:http://www.php-z.com/753.html



Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Empfehlungen
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!