From 16d3f423964ab4ef0ff674c5e8d59efab59cf947 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Fri, 4 Jan 2013 20:05:31 +0000 Subject: [PATCH] Ensure that get_archive_template() only loads a post type archive (archive-$post_type.php file) if there is exactly one post type in the query. Merges [23249] to the 3.5 branch. props scribu. see #22956. git-svn-id: http://core.svn.wordpress.org/branches/3.5@23271 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/template.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-includes/template.php b/wp-includes/template.php index d86a677fb6..99d004687b 100644 --- a/wp-includes/template.php +++ b/wp-includes/template.php @@ -59,12 +59,14 @@ function get_404_template() { * @return string */ function get_archive_template() { - $post_types = get_query_var( 'post_type' ); + $post_types = array_filter( (array) get_query_var( 'post_type' ) ); $templates = array(); - foreach ( (array) $post_types as $post_type ) + if ( count( $post_types ) == 1 ) { + $post_type = reset( $post_types ); $templates[] = "archive-{$post_type}.php"; + } $templates[] = 'archive.php'; return get_query_template( 'archive', $templates );