[wp-trac] [WordPress Trac] #59767: Front page template selection needs to be more granular

WordPress Trac noreply at wordpress.org
Mon Oct 30 15:47:30 UTC 2023


#59767: Front page template selection needs to be more granular
--------------------------+-------------------------
 Reporter:  flixos90      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  6.5
Component:  Themes        |    Version:
 Severity:  normal        |   Keywords:  2nd-opinion
  Focuses:  template      |
--------------------------+-------------------------
 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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59767>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list