From 033aac697c1c14379df65a3cec86f34f6602dbc5 Mon Sep 17 00:00:00 2001 From: westi Date: Wed, 28 Apr 2010 07:48:09 +0000 Subject: [PATCH] Introduce a template file for the Front Page of a site. Has priority over every other template which applies and falls back to the standard template flow for the page / list of posts. Fixes #6801 git-svn-id: http://svn.automattic.com/wordpress/trunk@14276 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/template-loader.php | 3 ++- wp-includes/theme.php | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/wp-includes/template-loader.php b/wp-includes/template-loader.php index 9911bb272..7c72a05e1 100644 --- a/wp-includes/template-loader.php +++ b/wp-includes/template-loader.php @@ -23,6 +23,7 @@ if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) : if ( is_404() && $template = get_404_template() ) : elseif ( is_search() && $template = get_search_template() ) : elseif ( is_tax() && $template = get_taxonomy_template() ) : + elseif ( is_front_page() && $template = get_front_page_template() ) : elseif ( is_home() && $template = get_home_template() ) : elseif ( is_attachment() && $template = get_attachment_template() ) : remove_filter('the_content', 'prepend_attachment'); @@ -43,4 +44,4 @@ if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) : return; endif; -?> \ No newline at end of file +?> diff --git a/wp-includes/theme.php b/wp-includes/theme.php index b312caba5..608d2ed11 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -844,7 +844,9 @@ function get_date_template() { /** * Retrieve path of home template in current or parent template. - * + * + * This is the template used for the page containing the blog posts + * * Attempts to locate 'home.php' first before falling back to 'index.php'. * * @since 1.5.0 @@ -857,6 +859,22 @@ function get_home_template() { return apply_filters('home_template', $template); } +/** + * Retrieve path of front-page template in current or parent template. + * + * Looks for 'front-page.php'. + * + * @since 3.0.0 + * @uses apply_filters() Calls 'front_page_template' on file path of template. + * + * @return string + */ +function get_front_page_template() { + global $wp_query; + + return apply_filters( 'front_page_template', locate_template( array('front-page.php') ) ); +} + /** * Retrieve path of page template in current or parent template. * @@ -1001,6 +1019,8 @@ function locate_template($template_names, $load = false, $require_once = true ) $located = ''; foreach ( $template_names as $template_name ) { + if ( !$template_name ) + continue; if ( file_exists(STYLESHEETPATH . '/' . $template_name)) { $located = STYLESHEETPATH . '/' . $template_name; break;