重命名您的home.php
模板文件为front-page.php
.
用WordPress的说法,“家”是Blog Posts Index. 该网站的首页是Front Page. 同样home.php
模板文件对应于Blog Posts Index 以及front-page.php
模板文件对应于Site Front Page, 以及is_home()
在上时,条件返回trueBlog Posts Index 而is_front_page()
在上时,条件返回trueSite Front Page.
总结如下:
- Site Front Page: 头版,
front-page.php
, is_front_page()
- Blog Posts Index: 家
home.php
, is_home()
EDIT:
如何将静态页面设置为博客文章索引:
创建两个具有任意名称的静态页面(我们称之为“首页”和“博客”)
转到:Dashboard -> Settings -> Reading
现在将“Front Page Displays”(首页显示)设置为“Static Page”(静态页面)在“Front Page”(首页)下拉列表中选择“Front Page”(首页)在“Posts Page”(贴子页面)下拉列表中选择“Blog”(博客)(假设您在Dashboard -> Settings -> Permalinks
):首页URL:www.example.com
博客帖子索引URL:www.example.com/blog/