Add single-{post_type}-{post_name}.php to the top of the template hierarchy for single posts.

This is consistent with page and taxonomy templates, which support slugs as well.

Props ericjuden, johnbillion.
Fixes #18859.
Built from https://develop.svn.wordpress.org/trunk@34800


git-svn-id: http://core.svn.wordpress.org/trunk@34765 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2015-10-03 15:00:25 +00:00
parent 9dc1a858f8
commit 3792591dfb
2 changed files with 6 additions and 2 deletions

View File

@ -380,6 +380,7 @@ function get_search_template() {
* e.g. 'single_template'. * e.g. 'single_template'.
* *
* @since 1.5.0 * @since 1.5.0
* @since 4.4.0 `single-{post_type}-{post_name}.php` was added to the top of the template hierarchy.
* *
* @see get_query_template() * @see get_query_template()
* *
@ -390,8 +391,11 @@ function get_single_template() {
$templates = array(); $templates = array();
if ( ! empty( $object->post_type ) ) if ( ! empty( $object->post_type ) ) {
$templates[] = "single-{$object->post_type}-{$object->post_name}.php";
$templates[] = "single-{$object->post_type}.php"; $templates[] = "single-{$object->post_type}.php";
}
$templates[] = "single.php"; $templates[] = "single.php";
return get_query_template( 'single', $templates ); return get_query_template( 'single', $templates );

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4-alpha-34799'; $wp_version = '4.4-alpha-34800';
/** /**
* 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.