Skip to content

Using blocks.registerBlockType block-filter to change core block markup. Is this how it's supposed to be done? #60685

Answered by bacoords
ts-mz asked this question in Q&A
Discussion options

You must be logged in to vote

I think a much simpler approach would be using a block variation to preload a Details block with a group block inside of it:

wp.blocks.registerBlockVariation( 
    'core/details', 
    {
		name: "details-with-div",
		title: "Details with div",
		innerBlocks: [
			[
				"core/group",
				{
					className: "this-is-my-container-div",
				},
				[["core/paragraph", { placeholder: "Summary" }]],
			],
		],
    }
);

Reference: https://developer.wordpress.org/block-editor/reference-guides/block-api/block-variations/

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@ts-mz
Comment options

@bacoords
Comment options

@justintadlock
Comment options

@bacoords
Comment options

@ts-mz
Comment options

Answer selected by ts-mz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants