From 02f76495c62fc099b142adbad569da6030960de4 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 3 Oct 2015 14:59:46 +0000 Subject: [PATCH] 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 --- src/wp-includes/template.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/template.php b/src/wp-includes/template.php index 3e4e9a403e..b6fe475a8a 100644 --- a/src/wp-includes/template.php +++ b/src/wp-includes/template.php @@ -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 );