-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add do_block_template_part function #30345
Conversation
Size Change: +380 B (0%) Total Size: 1.42 MB
ℹ️ View Unchanged
|
Thanks for exploring this! I think it'd be a nice way to gradually turn parts of a theme into block parts. Should we have more specific functions for semantic template parts (header and footer at the moment)? |
Makes sense... Added |
Would it be possible to adapt |
Yes, it would be possible, but only after Gutenberg gets merged in core. But I'm not sure if it would be better or not 🤔 |
One advantage I can see is that it would mean that block themes would work even if the site editor wasn't enabled. |
One more note on naming, since these functions don't take content directly (like |
Good point. Renamed them, removing the |
I followed the testing instructions and it is working well for me. It did get me thinking about if it would be reasonable to add the header and footer HTML elements as wrappers, |
I was looking at function gutenberg_block_template_part( $attributes ) {
echo do_blocks( sprintf( '<!-- wp:template-part %s /-->', json_encode( $attributes ) ) );
}
The concept I shared above, resolves the issue as well when the There are more benefits because it fully aligns the handling for the block with how it works in different contexts:
|
Description
Adds a
gutenberg_do_block_template_part()
function. This can be used by classic (non-FSE) themes that want to use a block template for their header and/or footer.How has this been tested?
block-template-parts/header.html
file from the TT1-Blocks theme to twentytwentyoneheader.php
file replace this line:<?php get_template_part( 'template-parts/header/site-header' ); ?>
with this:<?php gutenberg_block_header_area(); ?>
Your theme will now use the block-template instead of the PHP template for the header.
Checklist:
*.native.js
files for terms that need renaming or removal).cc @mtias