diff --git a/lib/full-site-editing.php b/lib/full-site-editing.php
index 059b39ccb971f0..2f3dd37f5316e8 100644
--- a/lib/full-site-editing.php
+++ b/lib/full-site-editing.php
@@ -11,7 +11,7 @@
* @return boolean Whether the current theme is an FSE theme or not.
*/
function gutenberg_is_fse_theme() {
- return is_readable( get_stylesheet_directory() . '/block-templates/index.html' );
+ return is_readable( locate_template( 'block-templates/index.html' ) );
}
/**
@@ -21,6 +21,7 @@ function gutenberg_full_site_editing_notice() {
if ( ! gutenberg_is_fse_theme() ) {
return;
}
+
?>
diff --git a/lib/template-loader.php b/lib/template-loader.php
index 601b64de7a629b..a5c306d6c7a63b 100644
--- a/lib/template-loader.php
+++ b/lib/template-loader.php
@@ -133,12 +133,32 @@ function gutenberg_resolve_template( $template_type, $template_hierarchy = array
'orderby' => 'post_name__in',
'posts_per_page' => -1,
'no_found_rows' => true,
+ // Templates that either:
+ //
+ // - the active theme has declared (stylesheet)
+ // - its parent theme (template) has declared but there's not an equivalent in the active theme
+ //
'tax_query' => array(
+ 'relation' => 'OR',
array(
'taxonomy' => 'wp_theme',
'field' => 'slug',
'terms' => wp_get_theme()->get_stylesheet(),
),
+ array(
+ 'relation' => 'AND',
+ array(
+ 'taxonomy' => 'wp_theme',
+ 'field' => 'slug',
+ 'terms' => wp_get_theme()->get_template(),
+ ),
+ array(
+ 'taxonomy' => 'wp_theme',
+ 'field' => 'slug',
+ 'terms' => wp_get_theme()->get_stylesheet(),
+ 'operator' => 'NOT IN'
+ ),
+ ),
),
)
);