W3cubDocs

/WordPress

_inject_theme_attribute_in_template_part_block( array $block )

Injects the active theme’s stylesheet as a theme attribute into a given template part block.

Parameters

$blockarrayrequired
a parsed block.

Source

function _inject_theme_attribute_in_template_part_block( &$block ) {
	if (
		'core/template-part' === $block['blockName'] &&
		! isset( $block['attrs']['theme'] )
	) {
		$block['attrs']['theme'] = get_stylesheet();
	}
}

Changelog

Version Description
6.4.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/_inject_theme_attribute_in_template_part_block