diff --git a/lib/compat/wordpress-6.1/block-template-utils.php b/lib/compat/wordpress-6.1/block-template-utils.php index 5e240d227d358..2005af46be5a2 100644 --- a/lib/compat/wordpress-6.1/block-template-utils.php +++ b/lib/compat/wordpress-6.1/block-template-utils.php @@ -80,7 +80,7 @@ function gutenberg_get_block_templates( $query = array(), $template_type = 'wp_t 'post_type' => $template_type, 'posts_per_page' => -1, 'no_found_rows' => true, - 'lazy_load_term_meta' => false, + 'lazy_load_term_meta' => false, // Do not lazy load term meta, as template post types only have one term. 'tax_query' => array( array( 'taxonomy' => 'wp_theme', diff --git a/packages/block-library/src/template-part/index.php b/packages/block-library/src/template-part/index.php index b0507e46464a2..54dc3f1b1179c 100644 --- a/packages/block-library/src/template-part/index.php +++ b/packages/block-library/src/template-part/index.php @@ -27,18 +27,19 @@ function render_block_core_template_part( $attributes ) { $template_part_id = $attributes['theme'] . '//' . $attributes['slug']; $template_part_query = new WP_Query( array( - 'post_type' => 'wp_template_part', - 'post_status' => 'publish', - 'post_name__in' => array( $attributes['slug'] ), - 'tax_query' => array( + 'post_type' => 'wp_template_part', + 'post_status' => 'publish', + 'post_name__in' => array( $attributes['slug'] ), + 'tax_query' => array( array( 'taxonomy' => 'wp_theme', 'field' => 'name', 'terms' => $attributes['theme'], ), ), - 'posts_per_page' => 1, - 'no_found_rows' => true, + 'posts_per_page' => 1, + 'no_found_rows' => true, + 'lazy_load_term_meta' => false, // Do not lazy load term meta, as template parts only have one term. ) ); $template_part_post = $template_part_query->have_posts() ? $template_part_query->next_post() : null;