Add multiple images to a custom block

There are other changes you need to make in your code, but as for the main one — making the mediaID and mediaURL be repeatable, the (core) gallery block did it by setting query as the attribute source and array as the attribute type. So I would do the same and for example you can … Read more

Style Gutenberg Editor based on Post Type or Page Template

Natively, no, not yet. I did find this helper plugin (and your question!) while searching for the same thing though: https://github.com/bigboxwc/wp-editor-page-template-class Clever JS based solution, it uses the Gutenberg Plugins API and props.selectedTemplate to generate a classname and add it to the editor. You could easily use the code from this plugin in your own … Read more

How to lock innerBlocks within a block variation?

I think I’ve figured this out. Instead of creating a block variation, I just created a brand new block using a block template. import { registerBlockType } from “@wordpress/blocks”; import { useBlockProps, InnerBlocks } from “@wordpress/block-editor”; const BLOCKS_TEMPLATE = [ [“core/heading”, { level: 2, placeholder: “Heading” }], [“core/gallery”, {}], ]; registerBlockType(“logo-grid”, { apiVersion: 2, title: … Read more