Add singular.php to template hierarchy

Singular is the only template context conditional that lacks a corresponding template. This allows some themes to simplify.

Fixes #22314.
Props chipbennett.


Built from https://develop.svn.wordpress.org/trunk@32846


git-svn-id: http://core.svn.wordpress.org/trunk@32817 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Aaron Jorbin 2015-06-18 19:01:26 +00:00
parent 09c4444150
commit 4b7ce555d0
3 changed files with 17 additions and 1 deletions

View File

@ -53,6 +53,7 @@ if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) :
remove_filter('the_content', 'prepend_attachment'); remove_filter('the_content', 'prepend_attachment');
elseif ( is_single() && $template = get_single_template() ) : elseif ( is_single() && $template = get_single_template() ) :
elseif ( is_page() && $template = get_page_template() ) : elseif ( is_page() && $template = get_page_template() ) :
elseif ( is_singular() && $template = get_singular_template() ) :
elseif ( is_category() && $template = get_category_template() ) : elseif ( is_category() && $template = get_category_template() ) :
elseif ( is_tag() && $template = get_tag_template() ) : elseif ( is_tag() && $template = get_tag_template() ) :
elseif ( is_author() && $template = get_author_template() ) : elseif ( is_author() && $template = get_author_template() ) :

View File

@ -382,6 +382,21 @@ function get_single_template() {
return get_query_template( 'single', $templates ); return get_query_template( 'single', $templates );
} }
/**
* Retrieve path of singular template in current or parent template.
*
* The template path is filterable via the 'singular_template' hook.
*
* @since 4.3.0
*
* @see get_query_template()
*
* @return string Full path to singular template file
*/
function get_singular_template() {
return get_query_template( 'singular' );
}
/** /**
* Retrieve path of attachment template in current or parent template. * Retrieve path of attachment template in current or parent template.
* *

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.3-alpha-32845'; $wp_version = '4.3-alpha-32846';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.