加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

使用wordpress遇到的坑:“混乱”的主题层级结构之首页模板,home.php front-page.php

发布时间:2020-05-25 02:54:46 所属栏目:PHP 来源:互联网
导读:本文章向大家介绍使用wordpress遇到的坑:“混乱”的主题层级结构之首页模板,home.php front-page.php,主要包括使用wordpress遇到的坑:“混乱”的主题层级结构之首页模板,home.php front-page.php使用实例、应用技巧、基本知识点总结和需要注意事项,具有

翻译自:https://www.rarst.net/wordpress/front-page-logic/

开始折腾wordpress,版本WP5;

万万没想到弄个首页被模板层级结构搞得晕头转向!!

抛开wordpress,但就语义上 homepage和 frontpage他妈的不是一样的么!!!可到了WP这里,麻蛋真恶心……

首页设置项在后台可以选择 最近博文 或者 固定页面,首页模板具体的继承规则有网友做了总结,这里记录一下,希望能帮助有需要的网友,当然啦,如果看WP codex文档会更好,但是也够够的了!

Default

默认

Static front page

当选择固定页面时

Front page displays

首页显示方式

Your latest posts

最近博文

Front page:


Front

首页样式

Posts page:


Posts

博文样式

URL

域名样式

example.com


(site URL)

网站域名

example.com/posts


(page URL)

页面伪静态域名

Template hierarchy

模板层级

front-page.php

使用font-page.php模板

home.php

使用home.php模板

home.php

$custom.php

page-$slug.php

page-$id.php

page.php

singular.php

index.php

Body classes

前台网页body标签的class样式名

home

blog

home

page

page-id-$id

blog

Loop and content

postsindex

page

postsindex

home_url()

内置函数的值

https://example.com

get_post_type_archive_link('post')

https://example.com

https://example.com/posts

is_front_page()

内置逻辑判断函数

true

false

is_home()

true

false

true

is_page()

false

true

false

get_option( 'show_on_front' )

'posts'

'page'

get_option( 'page_on_front' )

Front page ID

get_option( 'page_for_posts' )

Posts page ID

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读