Index: wp-includes/template.php
===================================================================
--- wp-includes/template.php	(revision 41072)
+++ wp-includes/template.php	(working copy)
@@ -40,7 +40,7 @@
 	 */
 	$templates = apply_filters( "{$type}_template_hierarchy", $templates );
 
-	$template = locate_template( $templates );
+	$template = locate_template( $templates, null, null, $type );
 
 	/**
 	 * Filters the path of the queried template by type.
@@ -613,6 +613,8 @@
 	return get_query_template( 'attachment', $templates );
 }
 
+
+
 /**
  * Retrieve the name of the highest priority template file that exists.
  *
@@ -626,16 +628,49 @@
  * @param bool         $require_once   Whether to require_once or require. Default true. Has no effect if $load is false.
  * @return string The template filename if one is located.
  */
-function locate_template($template_names, $load = false, $require_once = true ) {
-	$located = '';
+function locate_template($template_names, $load = false, $require_once = true, $type = null ) {
+
+    $located = '';
+
+    /**
+	 * Filters the path to the template files that are searched for when retrieving a template to use.
+	 *
+	 * If the filter is not triggered, the templates are expected to be in their default
+	 * location (the theme root).
+	 *
+	 * If the filter is triggered and a directory name is returned, then WordPress will
+	 * look in that directory (relative ancestor to the theme root) for the files.
+	 *
+	 * This filter also moves the location of all template parts such as header.php, footer.php ect ect
+	 * @since 4.7.0
+	 *
+	 * @param string $path A Directory name which contains all the template files, relative to the theme root.
+	 */
+    $path = apply_filters("templates_path", '');
+    $path = isset($path) ? trailingslashit($path) : $path;
+
+    /**
+     * Filters the path to the template files, based on type, that are searched
+     * for when retrieving a template to use.
+     *
+     *
+	 * Possible values for `$type` include: 'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date',
+	 * 'embed', 'home', 'frontpage', 'page', 'paged', 'search', 'single', 'singular', and 'attachment'.
+	 *
+     * @param string $path A Directory name which contains all the template files, relative to the theme root.
+     */
+    $path = apply_filters("{$type}_templates_path", $path);
+    $path = isset($path) ? trailingslashit($path) : $path;
+
+
 	foreach ( (array) $template_names as $template_name ) {
 		if ( !$template_name )
 			continue;
-		if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
-			$located = STYLESHEETPATH . '/' . $template_name;
+		if ( file_exists(STYLESHEETPATH . '/' . $path . $template_name)) {
+			$located = STYLESHEETPATH . '/' . $path . $template_name;
 			break;
-		} elseif ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
-			$located = TEMPLATEPATH . '/' . $template_name;
+		} elseif ( file_exists(TEMPLATEPATH . '/' . $path . $template_name) ) {
+			$located = TEMPLATEPATH . '/' . $path . $template_name;
 			break;
 		} elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) {
 			$located = ABSPATH . WPINC . '/theme-compat/' . $template_name;
