block_template_part( string $part )
Print a template-part.
Parameters
- $part
-
(string) (Required) The template-part to print. Use "header" or "footer".
Source
File: wp-includes/block-template-utils.php
function block_template_part( $part ) { $template_part = get_block_template( get_stylesheet() . '//' . $part, 'wp_template_part' ); if ( ! $template_part || empty( $template_part->content ) ) { return; } echo do_blocks( $template_part->content ); }
Expand full source code Collapse full source code View on Trac View on GitHub
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Note that this outputs the content of the template part, and does not use any parameters added to the template part itself.
In other words,
If you have a template part, and you are adding it inside a HTML block template in a block theme with these parameters:
Using block_template_part() to output the same template part in a PHP template, does not output the wrapping footer element and the
site-footer
CSS class.