'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;
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.
$content =
$template_part_post->post_content;
$area_terms =
get_the_terms( $template_part_post, 'wp_template_part_area'
);
if ( !
is_wp_error( $area_terms ) && false !==
$area_terms ) { $area =
$area_terms[0
]->name;
} /**
* Fires when a block template part is loaded from a template post stored in the database.
*
* @since 5.9.0
*
* @param string $template_part_id The requested template part namespaced to the theme.
* @param array $attributes The block attributes.
* @param WP_Post $template_part_post The template part post object.
* @param string $content The template part content.
*/