爱程序网

WordPress 主题开发

来源: 阅读:

Index.php is the most crucial WordPress Theme Template. Not only because WordPress needs to use it if you’re missing any of its brother and sister templates (like, archive.php or tag.php) but because the work we do here, getting this template right, will help us breeze through the rest of our templates (with the exception of the dreaded comments template; that’s just plain difficult no matter how you look at it). Please note: This lesson assumes that you have already added the basic HTML structural elements to your index.php file, which we covered in WordPress Theme Template and Directory Structure. If yourindex.php file is empty, please work through that lesson first, and then come right back.

Index.php是WordPress主题模板里面最关键的文件。不只是因为WordPress在缺失其它兄弟模板(如archive.php和tag.php)时使用它,还因为如果我们把这个模板写好了,整个主题模板 的其它部分也就轻而易举了。
注意:本课程假设你已经在index.php文件中加入了基本的HTML结构元素,这是在本课程的第五部分里面完成的,如果没有完成,请完成后再返回到本课题。(下面也会有这个基础的结构)

Calling in the Header
头部信息调用

Open up the index.php. We added some basic structural HTML inWordPress Theme Template and Directory Structure. Here’s whatindex.php looked like at the end of that lesson.
打开index.php。在上一课中我们添加了基本的HTML结构,如下代码是第五节课完成时的index.php。

<div id="primary" class="content-area"><div id="content" class="site-content"></div><!-- #content .site-content --></div><!-- #primary .content-area -->