wp的模板文件系统

WordPress模板基本文件

style.css 样式表文件

index.php 主页文件

single.php 日志单页文件

page.php 页面文件

archvie.php 分类和日期存档页文件

searchform.php 搜索表单文件

search.php 搜索页面文件

comments.php 留言区域文件(包括留言列表和留言框)

404.php 404错误页面

header.php 网页头部文件

sidebar.php 网页侧边栏文件

footer.php 网页底部文件

模板文件详细解

  • style.css

/* Theme Name: utubon.com Theme URI: http://www.phpstudio.info/ Description: wordpress Author: wordpress Version: 1.0 License: License URI: Tags: wordpress */

  • function.php
  • index.php

模板文件之间的调用

wordpress使用模板通过函数的调用,让模板之间形成完整的整体,例如在index.php中你会看到get_header()即调用文件名为header.php的模板文件, get_footer()亦然。get_template_part( 'loop', 'index' );则是调用模板loop-index.php。wordpress并非傻瓜的像include()函数一样包含这些文件,而是对文件的存在与否要进行判断,如果不存在该文件将用对应的相关文件代替,这需要你查看开发文档中该函数的具体解释。

文件名一般作用对应的函数备注
style.css样式表调用地址
index.phpwp识别首页自动识别
functions.php包含增函数和新功能自动识别
header.php头部get_header()
footer.php尾部get_footer
sidebar.php边侧栏get_sidebar('foot')(无参数则调用sidebar.php)参数foot指文件sidebar-foot.php类推
loop.php content.php内容循环get_template_part( 'loop', 'index' )和sidebar一样
404.php search.php single.php分别是404页,搜索页,单独页面,文章内容页自动识别,和index.php一样,使用上述函数,没有该文件的话用index.php参数的意思是调用模板loop-index.php类推如果get_template_part( 'content','single' );
archive.php category.php tag.php arthor.php分别是归档页,分类页,标签页,作者页同上,但如果只有archive.php或category.php没有其他页,其他页用archive.php代替或category.php代替