Skip to content

Commit

Permalink
Fix duplicate templates between database and theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Aljullu committed Nov 3, 2024
1 parent 657b0a8 commit 1d1af57
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/wp-includes/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1163,11 +1163,18 @@ function get_block_templates( $query = array(), $template_type = 'wp_template' )
}

if ( ! isset( $query['wp_id'] ) ) {
$template_files_query = $query;
/*
* If the query has found some user templates, those have priority
* over the theme-provided ones, so we skip querying and building them.
*/
$template_files_query = $query;
$template_files_query['slug__not_in'] = wp_list_pluck( $query_result, 'slug' );
/*
* We need to unset the post_type query param because some templates
* would be excluded otherwise, like `page.html` when looking for
* `page` templates.
* See: https://github.com/WordPress/gutenberg/issues/65584
*/
unset( $template_files_query['post_type'] );
$template_files = _get_block_templates_files( $template_type, $template_files_query );
foreach ( $template_files as $template_file ) {
Expand Down

0 comments on commit 1d1af57

Please sign in to comment.