Index: src/wp-includes/query.php
===================================================================
--- src/wp-includes/query.php	(revision 36101)
+++ src/wp-includes/query.php	(working copy)
@@ -4945,30 +4945,34 @@ class WP_Query {
 
 /**
  * Redirect old slugs to the correct permalink.
  *
  * Attempts to find the current slug from the past slugs.
  *
  * @since 2.1.0
  *
  * @global WP_Query   $wp_query   Global WP_Query instance.
  * @global wpdb       $wpdb       WordPress database abstraction object.
  * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
  */
 function wp_old_slug_redirect() {
 	global $wp_query, $wp_rewrite;
 
+	if ( get_queried_object() ) {
+		return;
+	}
+
 	if ( '' !== $wp_query->query_vars['name'] ) :
 		global $wpdb;
 
 		// Guess the current post_type based on the query vars.
 		if ( get_query_var( 'post_type' ) ) {
 			$post_type = get_query_var( 'post_type' );
 		} elseif ( get_query_var( 'attachment' ) ) {
 			$post_type = 'attachment';
 		} elseif ( ! empty( $wp_query->query_vars['pagename'] ) ) {
 			$post_type = 'page';
 		} else {
 			$post_type = 'post';
 		}
 
 		if ( is_array( $post_type ) ) {
