diff --git a/src/wp-includes/block-template.php b/src/wp-includes/block-template.php index 7030e2e2a19f5..67abf030b55a0 100644 --- a/src/wp-includes/block-template.php +++ b/src/wp-includes/block-template.php @@ -28,7 +28,7 @@ function _add_template_loader_filters() { * @global string $_wp_current_template_content * @global string $_wp_current_template_id * - * @param string $template Path to the template. See locate_template(). + * @param string $template Path to the template. * @param string $type Sanitized filename without extension. * @param string[] $templates A list of template candidates, in descending order of priority. * @return string The path to the Site Editor template canvas file, or the fallback PHP template. @@ -37,7 +37,7 @@ function locate_block_template( $template, $type, array $templates ) { global $_wp_current_template_content, $_wp_current_template_id; if ( ! current_theme_supports( 'block-templates' ) ) { - return $template; + return ''; } if ( $template ) { diff --git a/src/wp-includes/template.php b/src/wp-includes/template.php index 989d630f7fce4..3d71254681d08 100644 --- a/src/wp-includes/template.php +++ b/src/wp-includes/template.php @@ -61,10 +61,12 @@ function get_query_template( $type, $templates = array() ) { */ $templates = apply_filters( "{$type}_template_hierarchy", $templates ); - $template = locate_template( $templates ); - - $template = locate_block_template( $template, $type, $templates ); + $block_template = locate_block_template( '', $type, $templates ); + if ( $block_template ) { + return $block_template; + } + $template = locate_template( $templates ); /** * Filters the path of the queried template by type. *