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.

git-svn-id: https://develop.svn.wordpress.org/trunk@34800 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2015-10-03 14:59:46 +00:00
parent fb6b3313c7
commit 02f76495c6
1 changed files with 5 additions and 1 deletions

View File

@ -380,6 +380,7 @@ function get_search_template() {
* e.g. 'single_template'.
*
* @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()
*
@ -390,8 +391,11 @@ function get_single_template() {
$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.php";
return get_query_template( 'single', $templates );