[wp-hackers] front-page.php always overrides home.php?

Chip Bennett chip at chipbennett.net
Fri Nov 19 21:36:47 UTC 2010


(Not asking sarcastically) is there a logical way to define "home" other
than "front page"?

That is, "home" is whatever shows up by default for the domain:
www.domain.tld: whatever displays is "home".

And if that's the case, then is there really a (logical) use anymore for
"is_home()"? When a site is set to show blog posts on the front page, then
the front-page blog index is "home", and "is_front_page()" is true. But if a
site is set to show a static page on the front page, then blog posts are on
a non-"home" page, but "is_home()" is true in this condition.

(My only concern is that $wp_query->is_home is rather embedded in query.php.
Doing a proper replacement becomes non-trivial.)

Chip

On Fri, Nov 19, 2010 at 3:28 PM, Otto <otto at ottodestruct.com> wrote:

> That depends on how you define "home". ;)
>
> The home.php is a (deprecated) override for the index.php file. We
> used it before we had the ability to set your own Page as the first
> page. No theme should contain a home.php any more, IMO, since you can
> now define any Page as the first page.
>
> The front-page.php is the overall override for the first page of the
> site, period. It's always the front page, if it exists.
>
> -Otto
>
>
>
> On Fri, Nov 19, 2010 at 3:15 PM, Chip Bennett <chip at chipbennett.net>
> wrote:
> > Exactly!
> >
> > So "home.php" ISN'T "home". It's simply the blog-index (posts-index),
> > whether on the front page or another page.
> >
> > front-page.php and is_front_page() cover all of the uses of home.php and
> > is_home() for both posts-index-as-home and static-page-as-home - which is
> > why I'm suggesting to rename "home.php" and "is_home()" to something more
> > accurate.
> >
> > Make sense, or am I still off-base?
> >
> > Chip
> >
> > On Fri, Nov 19, 2010 at 3:08 PM, Chris Gossmann <chris at wupperpiraten.de
> >wrote:
> >
> >> Ok .. did a test:
> >>
> >> If you have a standard installation without any special setting under
> >> wp-admin / settings / reading:
> >>
> >> Front-page.php will be used as your entry page. Home.php isn't used at
> all.
> >>
> >> If you define a page as Front page and a page as Posts page under
> wp-admin
> >> /
> >> settings / reading:
> >>
> >> Front-page.php will be used for Front page and home.php for your Posts
> >> page.
> >>
> >> > -----Ursprüngliche Nachricht-----
> >> > Von: wp-hackers-bounces at lists.automattic.com [mailto:wp-hackers-
> >> > bounces at lists.automattic.com] Im Auftrag von Chip Bennett
> >> > Gesendet: Freitag, 19. November 2010 21:58
> >> > An: wp-hackers at lists.automattic.com
> >> > Betreff: Re: [wp-hackers] front-page.php always overrides home.php?
> >> >
> >> > I'm not confusing the two, as far as I know.
> >> >
> >> > Simple question: if "front-page.php" and "home.php" template files
> both
> >> > exist in a Theme, under what conditions will "home.php" be used on the
> >> > home/front page of the site using that Theme?
> >> >
> >> > Chip
> >> >
> >> > On Fri, Nov 19, 2010 at 2:54 PM, Chris Gossmann
> >> > <chris at wupperpiraten.de>wrote:
> >> >
> >> > > Seems as if you're mixing up front-page.php and front page template
> >> > :)
> >> > >
> >> > > The existence of a front-page.php will always enforce the use of
> this
> >> > file
> >> > > as entry page of your blog. A front page template is a template file
> >> > with a
> >> > > different name that is activated by creating a page using this
> >> > template and
> >> > > the according settings under wp-admin / settings / reading.
> >> > >
> >> > > > -----Ursprüngliche Nachricht-----
> >> > > > Von: wp-hackers-bounces at lists.automattic.com [mailto:wp-hackers-
> >> > > > bounces at lists.automattic.com] Im Auftrag von Chip Bennett
> >> > > > Gesendet: Freitag, 19. November 2010 21:27
> >> > > > An: wp-hackers at lists.automattic.com
> >> > > > Betreff: Re: [wp-hackers] front-page.php always overrides
> home.php?
> >> > > >
> >> > > > Thanks, Chris.
> >> > > >
> >> > > > But, does that make sense?
> >> > > >
> >> > > > If a Theme includes both template files "front-page.php" and
> >> > > > "home.php", the
> >> > > > Blog index will display differently, depending on user settings:
> >> > > >
> >> > > > If Blog (i.e. "posts") is set to display on the front page, then
> >> > the
> >> > > > Blog
> >> > > > index will use "front-page.php"; however, if the front page is set
> >> > to
> >> > > > display a static Page, and the Blog set to display on a non-front
> >> > Page,
> >> > > > then
> >> > > > the Blog index will use "home.php".
> >> > > >
> >> > > > That seems inconsistent (and confusing) to me:
> >> > > >
> >> > > > 1) Blog display will be different depending on location setting,
> >> > rather
> >> > > > than
> >> > > > by content type (Page vs Post)
> >> > > > 2) "*home*.php" is potentially used for a non-home page.
> >> > > > 3) "front-*page*.php" is used for both Pages and Posts.
> >> > > >
> >> > > > I've not poked around Trac yet; does anyone know if any related
> >> > tickets
> >> > > > have
> >> > > > been opened? I think some of this needs some cleaning-up.
> >> > > >
> >> > > > Chip
> >> > > >
> >> > > > On Fri, Nov 19, 2010 at 2:20 PM, Chris Gossmann
> >> > > > <chris at wupperpiraten.de>wrote:
> >> > > >
> >> > > > > Hi Chip,
> >> > > > >
> >> > > > > this is the correct behavior.
> >> > > > >
> >> > > > > Front-page is always the front page / first page, whereas home
> >> > could
> >> > > > be
> >> > > > > your
> >> > > > > home / first page or whatever you defined to show your regular
> >> > posts.
> >> > > > > Therefore front-page.php will override home.php.
> >> > > > >
> >> > > > > Chris
> >> > > > >
> >> > > > > > -----Ursprüngliche Nachricht-----
> >> > > > > > Von: wp-hackers-bounces at lists.automattic.com [mailto:wp-
> >> > hackers-
> >> > > > > > bounces at lists.automattic.com] Im Auftrag von Chip Bennett
> >> > > > > > Gesendet: Freitag, 19. November 2010 20:38
> >> > > > > > An: wp-hackers at lists.automattic.com
> >> > > > > > Betreff: [wp-hackers] front-page.php always overrides
> home.php?
> >> > > > > >
> >> > > > > > All,
> >> > > > > >
> >> > > > > > If a Theme defines both a "home.php" template file (for a
> >> > custom
> >> > > > "home"
> >> > > > > > page
> >> > > > > > displaying Posts) and a "front-page.php" template file (for a
> >> > > > custom
> >> > > > > > "home"
> >> > > > > > page displaying a static Page), it appears that "front-
> >> > page.php"
> >> > > > will
> >> > > > > > always
> >> > > > > > take precedence over "home.php":
> >> > > > > >
> >> > > > > > Here's the definition of
> >> > > > > >
> >> > > >
> >> > is_front_page()<http://core.trac.wordpress.org/browser/tags/3.0.1/wp-
> >> > > > > > includes/query.php#L353>
> >> > > > > > :
> >> > > > > >
> >> > > > > > 344     /**
> >> > > > > > 345  * Whether current page query is the front of the site.
> >> > > > > > 346  *
> >> > > > > > 347  * @since 2.5.0
> >> > > > > > 348  * @uses is_home()
> >> > > > > > 349  * @uses get_option()
> >> > > > > > 350  *
> >> > > > > > 351  * @return bool True, if front of site.
> >> > > > > > 352  */
> >> > > > > > 353 function is_front_page() {
> >> > > > > > 354         // most likely case
> >> > > > > > *355         if ( 'posts' == get_option('show_on_front') &&
> >> > > > is_home()
> >> > > > > > )*
> >> > > > > > 356                 return true;
> >> > > > > > 357         elseif ( 'page' == get_option('show_on_front') &&
> >> > > > > > get_option('page_on_front') &&
> >> > is_page(get_option('page_on_front'))
> >> > > > )
> >> > > > > > 358                 return true;
> >> > > > > > 359         else
> >> > > > > > 360                 return false;
> >> > > > > > 361 }
> >> > > > > >
> >> > > > > > And then here's the relevant code from the template
> >> > > > > > loader<http://core.trac.wordpress.org/browser/trunk/wp-
> >> > > > > > includes/template-loader.php#L21>
> >> > > > > > :
> >> > > > > >
> >> > > > > > 21 if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) :
> >> > > > > > 22         $template = false;
> >> > > > > > 23         if     ( is_404()            && $template =
> >> > > > > > get_404_template()
> >> > > > > >          ) :
> >> > > > > > 24         elseif ( is_search()         && $template =
> >> > > > > > get_search_template()
> >> > > > > >         ) :
> >> > > > > > 25         elseif ( is_tax()            && $template =
> >> > > > > > get_taxonomy_template()       ) :
> >> > > > > > *26         elseif ( is_front_page()     && $template =
> >> > > > > > get_front_page_template()     ) :*
> >> > > > > > *27         elseif ( is_home()           && $template =
> >> > > > > > get_home_template()
> >> > > > > >           ) :*
> >> > > > > > 28         elseif ( is_attachment()     && $template =
> >> > > > > > get_attachment_template()     ) :
> >> > > > > > 29                 remove_filter('the_content',
> >> > > > 'prepend_attachment');
> >> > > > > > 30         elseif ( is_single()         && $template =
> >> > > > > > get_single_template()
> >> > > > > >         ) :
> >> > > > > > 31         elseif ( is_page()           && $template =
> >> > > > > > get_page_template()
> >> > > > > >         ) :
> >> > > > > > 32         elseif ( is_category()       && $template =
> >> > > > > > get_category_template()       ) :
> >> > > > > > 33         elseif ( is_tag()            && $template =
> >> > > > > > get_tag_template()
> >> > > > > >          ) :
> >> > > > > > 34         elseif ( is_author()         && $template =
> >> > > > > > get_author_template()
> >> > > > > >         ) :
> >> > > > > > 35         elseif ( is_date()           && $template =
> >> > > > > > get_date_template()
> >> > > > > >         ) :
> >> > > > > > 36         elseif ( is_archive()        && $template =
> >> > > > > > get_archive_template()        ) :
> >> > > > > > 37         elseif ( is_comments_popup() && $template =
> >> > > > > > get_comments_popup_template() ) :
> >> > > > > > 38         elseif ( is_paged()          && $template =
> >> > > > > > get_paged_template()
> >> > > > > >          ) :
> >> > > > > > 39         else :
> >> > > > > > 40                 $template = get_index_template();
> >> > > > > > 41         endif;
> >> > > > > > 42         if ( $template = apply_filters( 'template_include',
> >> > > > > > $template ) )
> >> > > > > > 43                 include( $template );
> >> > > > > > 44         return;
> >> > > > > > 45 endif;
> >> > > > > >
> >> > > > > > Is this the intended behavior? If so, it would seem to make
> the
> >> > use
> >> > > > of
> >> > > > > > "home.php" obsolete, since "front-page.php" covers both use
> >> > cases.
> >> > > > > >
> >> > > > > > (And sorry for the incredibly belated question. I know that
> >> > "front-
> >> > > > > > page.php"
> >> > > > > > has been around for a year. I've just never actually *used*
> it,
> >> > so
> >> > > > > > wasn't
> >> > > > > > aware of how it was defined/used by the template loader.)
> >> > > > > >
> >> > > > > > Chip
> >> > > > > > _______________________________________________
> >> > > > > > wp-hackers mailing list
> >> > > > > > wp-hackers at lists.automattic.com
> >> > > > > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >> > > > >
> >> > > > > _______________________________________________
> >> > > > > wp-hackers mailing list
> >> > > > > wp-hackers at lists.automattic.com
> >> > > > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >> > > > >
> >> > > > _______________________________________________
> >> > > > wp-hackers mailing list
> >> > > > wp-hackers at lists.automattic.com
> >> > > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >> > >
> >> > > _______________________________________________
> >> > > wp-hackers mailing list
> >> > > wp-hackers at lists.automattic.com
> >> > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >> > >
> >> > _______________________________________________
> >> > wp-hackers mailing list
> >> > wp-hackers at lists.automattic.com
> >> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >>
> >> _______________________________________________
> >> wp-hackers mailing list
> >> wp-hackers at lists.automattic.com
> >> http://lists.automattic.com/mailman/listinfo/wp-hackers
> >>
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list