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

Support block patterns in post type templates #36323

Closed
ethanclevenger91 opened this issue Nov 8, 2021 · 1 comment
Closed

Support block patterns in post type templates #36323

ethanclevenger91 opened this issue Nov 8, 2021 · 1 comment
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Feature] Templates API Related to API powering block template functionality in the Site Editor [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed

Comments

@ethanclevenger91
Copy link

ethanclevenger91 commented Nov 8, 2021

What problem does this address?

Registered block patterns can't subsequently be referenced within the template argument passed to register_post_type:

register_block_pattern('namespace/block-pattern-name', [
	'title' => 'My Block Pattern',
	'content' => '<!-- ... -->',
]);

// ...

register_post_type( 'my-post-type', [
	'template' => [
		[
			'namespace/block-pattern-name',
		],
	],
) );

And due to #33379, this means you have to maintain both the HTML string version of a block pattern to use in register_block_pattern so it can be inserted on-demand, plus a PHP array version of the block pattern for use in a template default. Not very DRY.

What is your proposed solution?

Support block pattern names within the template arg of register_post_type.

It's possible I'm simply "doing it wrong", but I do not see documentation suggesting this is or isn't currently supported.

@talldan
Copy link
Contributor

talldan commented Nov 9, 2021

@ethanclevenger91 I don't think it has been historically supported. There is a new block type called the pattern block, so an option would be to use this in a template and make that block reference a specific pattern.

There's a very similar request here - #21830. I'm going to close this issue as a duplicate and leave more detailed feedback on #21830.

@talldan talldan closed this as completed Nov 9, 2021
@talldan talldan added [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Feature] Templates API Related to API powering block template functionality in the Site Editor [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed labels Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Feature] Templates API Related to API powering block template functionality in the Site Editor [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed
Projects
None yet
Development

No branches or pull requests

2 participants