Opened 15 years ago
Closed 13 years ago
#6801 closed enhancement (fixed)
Should have a template file for front page
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Template | Keywords: | has-patch tested commit |
Focuses: | Cc: |
Description
Now that we have is_front_page() in addition to is_home(), I think we should have a template file for it. I'm suggesting that we use front-page.php falling back on home.php then index.php. I'm attaching a patch.
Attachments (10)
Change History (60)
#3
@
15 years ago
The new diff (6801.002.diff), changes the fall-back order, actually creating a fork in order to keep backwards compatibility. If the user uses posts as the front page, it uses:
front-page.php -> home.php -> index.php
If the user uses a static page:
customTemplate -> front-page.php -> page.php -> index.php
#4
@
15 years ago
- Resolution set to wontfix
- Status changed from new to closed
This change would require that a theme developer that includes a front-page.php use an if-else in that file to see if it's for posts or if it's a page. They can already do this in another page to accomplish the same basic thing.
While it would be handy in my cases, it would be less handy for others.
#5
@
15 years ago
- Resolution wontfix deleted
- Status changed from closed to reopened
Trying to keep up with opinions here. It looks like it could still be useful. However, home.php is for the front page if it's posts. So, since that case is already handled, lets make this one handle just a static front page. This options does that, with the static front page going to:
CustomTemplate -> front-page.php -> page.php -> index.php
#7
@
15 years ago
- Milestone changed from 2.7 to 2.9
The problem with this at the moment is that if you have posts on the front_page then the home template is going to win over the front_page template.
I have a feeling that front_page might want to win over home and in effect home should be come deprecated.
not sure this is 2.7 ready yet.
needs some discussion first
#8
@
15 years ago
Westi: I honestly prefer it your way, I was just trying to go for backwards compatibility. I don't use WordPress as blogging software, I use it as a CMS that has blogging software built in.
#11
@
14 years ago
In my opinion, "home page" and "front page" are normally used synonymously in the context of a website. I'd sure like home.php to be the default template file for the front/home page of the site, regardless of whether that page incorporates blog posts or not.
I've posted to the forum about this in an effort to gather more opinions.
#12
@
14 years ago
- Milestone changed from 2.8 to Future Release
Punting due to time constraints, will be reconsidered in next release cycle.
#13
@
14 years ago
I'd rather see a blog.php template for a blog page that is set on a static front page
#17
@
14 years ago
Lol...this one's bouncing around quite a bit. Did we decide how we want this to be implemented? I'd be happy to write the patch for it (and I do think 2.9 is the right place for it, I wasn't complaining).
#20
in reply to:
↑ 19
@
14 years ago
Replying to Denis-de-Bernardy:
+1 for front page.php
As in, you'd like it to just fall back to page.php and have a theme author use is_front_page to fork that page into separate logic (if needed) to handle the front page one way and other pages another way?
#21
follow-up:
↓ 22
@
14 years ago
Personally, I'd suggest page template (if any) then try front-page.php, then home.php, then try page.php for best compat.
#22
in reply to:
↑ 21
@
14 years ago
Replying to Denis-de-Bernardy:
Personally, I'd suggest page template (if any) then try front-page.php, then home.php, then try page.php for best compat.
That should be refined, I think:
If static front page set:
custom template > front-page.php > page.php > index.php
If not a static front page:
front-page.php > home.php > index.php
home.php should not be considered for the front page, when a static front page is set, because is_home() will be false for the front page.
#23
follow-up:
↓ 24
@
14 years ago
mm, for backwards compat it's probably better to keep home.php in there for static front pages.
#24
in reply to:
↑ 23
@
14 years ago
Replying to Denis-de-Bernardy:
mm, for backwards compat it's probably better to keep home.php in there for static front pages.
How is that backwards-compatible? home.php currently loads only when is_home() is true, unless I'm missing something.
#25
@
14 years ago
Doesn't it load when is_front_page() returns true? If not, you're 100% correct -- ignore my last comment. (I never use these, myself.)
#26
@
14 years ago
template_loader.php just has:
} else if ( is_home() && $template = get_home_template() ) {
so I think it should go: Custom Template -> front-page.php -> page.php -> index.php
I'll try to update the patch (if it needs it...I haven't looked, but it's old) tomorrow.
#27
@
14 years ago
how about using:
if ( is_front_page() && !is_home() && $template = get_front_page_template() ) { } else if ( is_home() && $template = get_home_template() ) { }
and then, in get_home_template(), we add a check: if is_front_page() and try front-page.php.
the case to avoid is, if it's a static front page, we want to behave like a page, but if it's a blog front page, we'd also want to catch front-page.php.
#28
@
14 years ago
Denis: This was written before your reply:
6801.005.diff is the latest patch based off the current trunk.
I looked into is_front_page, and it returns true if show_on_front is 'posts' and is_home is true. However, that seems a little redundant unless some plugin is messing with it, because in query.php starting at line 1460 is_home is set to false if show_on_front == 'page'
The patch adds a check for is_front_page AFTER the is_home check. This means that if the blog page is the front page it checks for home.php -> custom template -> front-page.php -> page.php -> index.php. If the front page is a static page, it checks custom template -> front-page.php -> page.php -> index.php.
I think that makes sense.
#29
@
14 years ago
seems so. thoughts on making front-page.php work for is_home() on the front page?
#30
@
14 years ago
- Keywords has-patch added; needs-patch removed
uploaded a patch that adds front-page.php to is_home()
#33
@
14 years ago
I added 6801.006.diff ...I think the only difference functionally is that Denis' would go front-page.php -> home.php -> index.php for a blog on the front. Mine would go home.php -> front-page.php -> index.php for the same.
#35
in reply to:
↑ 34
@
14 years ago
Replying to thee17:
I don't agree with home.php being used for a static page.
Neither of the available patches here do that.
#36
follow-up:
↓ 37
@
14 years ago
- Keywords tested added
actually, there's a bit more difference.
Aaron's does:
- static front: page template -> front-page.php -> page.php -> index.php
- blog: home.php -> index.php
Mine does:
- static front: page template -> front-page.php -> page.php -> index.php
- blog front: front-page.php -> home.php -> index.php
- blog: home.php -> index.php
#37
in reply to:
↑ 36
@
14 years ago
Actually, mine does:
- static front: page template -> front-page.php -> page.php -> index.php
- blog front: home.php -> front-page.php -> page.php -> index.php
- blog: home.php -> index.php
The reason mine has that functionality for blog front is because it first tried is_home and if that's true but home.php doesn't exist, it then tests is_front_page and goes through it's flow.
#38
@
14 years ago
I meant to put this in the last message, but the differences as I see them are that mine prefers home to front-page if the front-page is a blog, and mine also travels through page.php for a blog front page. I think that last one is really the issue, and for that reason Denis' fix is probably better.
#41
@
14 years ago
@westi -- I'm pretty certain you'll wonder about this:
front-page.php -> page template -> page.php
rather than:
page template -> front-page.php -> page.php
the reasoning is, if a user specifies a page template (e.g. a sales letter template), he means it and wants that on the front page.
#43
@
13 years ago
- Keywords commit removed
Been thinking about this a bit while reviewing this patch and have the following counter proposal:
- is_home() stays as is and always does home.php -> index.php
- is_front_page() is put at a higher priority than is_home() and does:
- For page on front: front-page.php -> _wp_page_template -> page-slug.php -> page-id.php -> page.php
- For posts on front: front-page.php -> home.php -> index.php
This way for is_front_page()
the most specific template gets used first and I think gives the most consistent behaviour for theme developers.
If they put a front-page.php in the theme it will always be used for the root of the site whatever the config.
Then depending on the type of post on the front page we follow the normal rules for that type.
New patch incoming for discussion.
Removing commit for now.
#44
@
13 years ago
Quickly reviewed your patch global $wp_query;
looks like a leftover from copy/paste.
#47
@
13 years ago
Just thought I'd chime in and say that while it seems to me that a page template should override the front-page.php file, that's a pretty minor issue and I'm fine with Westi's patch.
#48
@
13 years ago
- Keywords tested commit added
6801.3.diff additionally fixes a bug in the templating engine that I ran into while testing.
works as expected -- it loads the correct template for static front pages and for blog post pages.
I'm sorry, that should have been 2.6 from the beginning. I'm not sure how/why I set it to 2.5.1