admin管理员组文章数量:1125628
When I open up my WordPress site, and on the admin - settings - reading I define Your home page display posts as "Your latest posts" The homepage is displayed by home.php and /blog/ is displayed by blog.php. When I change the "Your homepage displays" as "static page" and select Homepage as "home" page and blog as "blog" page, the /blog shows the home.php page and the homepage shows the page.php page. Why is that?
When I open up my WordPress site, and on the admin - settings - reading I define Your home page display posts as "Your latest posts" The homepage is displayed by home.php and /blog/ is displayed by blog.php. When I change the "Your homepage displays" as "static page" and select Homepage as "home" page and blog as "blog" page, the /blog shows the home.php page and the homepage shows the page.php page. Why is that?
Share Improve this question asked Mar 23, 2024 at 13:56 Ronen YahalomsRonen Yahaloms 111 bronze badge1 Answer
Reset to default 0WordPress started as an outright blogging platform and nothing more, so the home page was always just meant to be the most recent blog entries, in its early iterations.
The template hierarchy has evolved since then but a lot of the labels have remained from that era. (Backwards compatibility and such.) So the page.php
file was a later addition to WP and home.php
file was the default (as a blog feed) because that was how WP started out. You can check out the full hierarchy here.
https://developer.wordpress.org/themes/basics/template-hierarchy/
In short, because of legacy, home.php
in a theme assumes that you're looking at the front page of a site that is set to having it's posts listed on it. (Like original WP.)
If you change it to static, WordPress then interprets that as you NOT wanting your front page to be a list of posts, so instead it assigns the default page.php
template so that you can layout content however you see fit.
Additional templates you can have include front-page.php
which overrides home.php
, but you can also make whatever templates you like, for example: gorilla-ears.php
and then you can assign that to the page you've set as HOME in the WP Settings. And that page can have whatever mark-up and code you want it to have.
本文标签:
版权声明:本文标题:Wordpress "Blog" template hierarchy 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736603208a1945266.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论