Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now that WP_Query is cached, just load all templates. #47253

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions packages/block-library/src/template-part/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,25 @@ function render_block_core_template_part( $attributes ) {
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,
'posts_per_page' => -1,
'no_found_rows' => true,
)
);
$template_part_post = $template_part_query->have_posts() ? $template_part_query->next_post() : null;
$template_part_post = null;
if ( $template_part_query->have_posts() ) {
foreach ( $template_part_query->posts as $template_post ) {
if ( $template_post->post_name === $attributes['slug'] ) {
$template_part_post = $template_post;
}
}
}
if ( $template_part_post ) {
// A published post might already exist if this template part was customized elsewhere
// or if it's part of a customized template.
Expand Down
Loading