Make WordPress Core

Opened 7 months ago

Last modified 4 months ago

#59767 new enhancement

Front page template selection needs to be more granular

Reported by: flixos90's profile flixos90 Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Themes Keywords: 2nd-opinion has-patch
Focuses: template Cc:


While #59759 has been focused on a concern with the TT4 home.html template, the reason why it came up as a problem in the first place is because TT4 chose to use the home.html template for the front page. That shouldn't be the case, but whichever path a block theme takes, there is no appropriate solution for the problem. Here's why:

  • If you have only a home.html template, it won't be used for the static front page.
  • If you have a front-page.html template and a home.html template, the front-page.html template will be used for the front page regardless of whether it is configured to display a static front page or the blog.

This was fine when we were using classic themes, as those themes would simply include a if ( is_home() ) { /* Show blog posts. */ } else { /* Show static page content. */ } in their PHP front-page.php template. But you can't do that in block theme templates, so we'll need a more appropriate solution. You cannot achieve this in block themes at the moment. That's why this is a bug ticket more than an enhancement.

I think there is a rather straightforward way to solve this problem for block themes, while also providing the same additional flexibility for classic theme templates:

  • For the front page, WordPress core should support an additional layer of templates, either front-page-home or front-page-static (depending on whether the home page is configured to show the blog or a static page).
  • Block themes could then provide front-page-home.html, front-page-static.html, and home.html, and thus would have the ability to cater for all 3 types of content.
  • Existing block themes wouldn't have any problem though, as in case front-page-home.html / front-page-static.html aren't present, WordPress core would still load front-page.html.
  • For classic themes, it wouldn't change much, just that they would now optionally be able to split their front-page.php template into two more distinct front-page-home.php and front-page-static.php templates.

Of course the home and static suffixes for the new front-page-* templates were just my initial ideas, there may be better names for those. My thinking behind those names is that home is aligned with the existing home.html (which is for better or worse synonymous with the blog in WordPress, e.g. is_home() returns true when on the blog page), while static simply describes the option of choosing a static page. Maybe blog would be more descriptive than home? Curious to hear others' thoughts.

Change History (3)

This ticket was mentioned in Slack in #core-themes by flixos90. View the logs.

7 months ago

This ticket was mentioned in PR #5592 on WordPress/wordpress-develop by @flixos90.

7 months ago

  • Keywords has-patch added

This is an early draft PR for addressing the limitations outlined in the ticket below.

You can test it with any block theme or classic theme. For example with TT4:

  • Rename home.html to front-page-static.html.
  • Configure your WordPress site to show a static front page. You'll see that the front page will show the content in front-page-static.html.
  • Configure your WordPress site to show the latest posts on the front page. You'll see that the front page will show the content in index.html (which is the last fallback value for that template.
  • You could also duplicate index.html and rename it to front-page-home.html to achieve similar behavior.
  • Additionally, you could introduce a generic front-page.html template that would act as a fallback in case the front page is configured to neither display the latest posts nor a static front page. Realistically, this is not possible today per WordPress core limitations, but it goes to show this would support a future where the front page could be configured to show something different, or simply whatever the template includes.

Trac ticket:

#3 @swissspidy
4 months ago

  • Milestone changed from 6.5 to Future Release
  • Type changed from defect (bug) to enhancement

6.5 Beta is approaching soon and there hasn't been any traction on this in a while. More discussion is needed for this enhancement. Punting for now so it can be picked up in the next cycle.

Note: See TracTickets for help on using tickets.