Index: wp-includes/template.php
===================================================================
--- wp-includes/template.php
+++ wp-includes/template.php
@@ -367,15 +367,23 @@
  */
 function locate_template($template_names, $load = false, $require_once = true ) {
 	$located = '';
+	$template_stack = get_template_stack();
+
 	foreach ( (array) $template_names as $template_name ) {
-		if ( !$template_name )
+		if ( empty( $template_name ) )
 			continue;
-		if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
-			$located = STYLESHEETPATH . '/' . $template_name;
-			break;
-		} else if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
-			$located = TEMPLATEPATH . '/' . $template_name;
-			break;
+
+		$template_name = ltrim( $template_name, '/' );
+
+		foreach ( (array) $template_stack as $template_location ) {
+			// Continue if $template_location is empty
+			if ( empty( $template_location ) )
+				continue;
+
+			if ( file_exists( trailingslashit( $template_location ) . $template_name ) ) {
+				$located = trailingslashit( $template_location ) . $template_name;
+				break 2;
+			}
 		}
 	}
 
@@ -409,3 +417,106 @@
 		require( $_template_file );
 }
 
+/**
+ * This function adds a new template stack location.
+ *
+ * This allows for templates to live in places beyond just the parent/child
+ * relationship, to allow for custom template locations. Used in conjunction
+ * with locate_template(), this allows for easy template overrides.
+ *
+ * @since 3.6.0
+ *
+ * @param string $location Path to template files
+ * @param int $priority
+ *
+ * @return bool True if added.
+ */
+function add_template_stack( $location, $priority = 10 ) {
+	global $wp_template_stack;
+
+	$idx = md5( $location );
+	$r = ! isset( $wp_template_stack[ $priority ][ $idx ] );
+
+	if ( $r === true )
+		$wp_template_stack[ $priority ][ $idx ] = $location;
+
+	return $r;
+}
+
+/**
+ * This function removes a template stack location.
+ *
+ * @since 3.6.0
+ *
+ * @param string $location Path to template files
+ * @param int $priority
+ *
+ * @return bool True if removed.
+ */
+function remove_template_stack( $location, $priority = 10 ) {
+	global $wp_template_stack;
+
+	$idx = md5( $location );
+	$r = isset( $wp_template_stack[ $priority ][ $idx ] );
+
+	if ( $r === true )
+		unset( $wp_template_stack[ $priority ][ $idx ] );
+
+	return $r;
+}
+
+/**
+ * This function checks if a template stack location exists.
+ *
+ * @since 3.6.0
+ *
+ * @param string $location Path to template files
+ *
+ * @return bool True if found.
+ */
+function has_template_stack( $location ) {
+	global $wp_template_stack;
+
+	$idx = md5( $location );
+
+	// Loop through template locations
+	foreach ( (array) $wp_template_stack as $stacks ) {
+		if ( array_key_exists( $idx, $stacks ) )
+			return true;
+	}
+
+	return false;
+}
+
+/**
+ * Return an array of the template locations added to the $wp_template_stack.
+ *
+ * @since 3.6.0
+ *
+ * @return array Template locations.
+ */
+function get_template_stack() {
+	global $wp_template_stack;
+
+	// Setup default variables
+	$stack = array();
+	if ( ! is_array( $wp_template_stack ) )
+		$wp_template_stack = array();
+
+	// Sort
+	ksort( $wp_template_stack );
+
+	// Ensure we're always at the beginning of the array
+	reset( $wp_template_stack );
+
+	// Loop through template locations
+	foreach ( $wp_template_stack as $stacks ) {
+		foreach ( $stacks as $location )
+			$stack[] = $location;
+	}
+
+	// Remove empties and duplicates
+	$stack = array_unique( array_filter( $stack ) );
+
+	return (array) apply_filters( 'get_template_stack', $stack );
+}
Index: wp-settings.php
===================================================================
--- wp-settings.php
+++ wp-settings.php
@@ -266,6 +266,10 @@
 // Define the template related constants.
 wp_templating_constants(  );
 
+// Register the parent/child template stack
+add_template_stack( get_stylesheet_directory(), 10 );
+add_template_stack( get_template_directory(), 12 );
+
 // Load the default text localization domain.
 load_default_textdomain();
 
