'Restrict Gutenberg Blocks to Single Use
I've got my blocks registered properly and functioning.
My only gripe is that I don't want the blocks to be used more than once in the same post.
Is it possible to restrict block behavior like this? The documentation is horrible.
Solution 1:[1]
When registering your own blocks, you can set the multiple option of the supports property to false:
supports: {
// Use the block just once per post
multiple: false
}
Source: https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#multiple.
Solution 2:[2]
in block.json set "multiple" to false in "supports":
"category": "widgets",
"icon": "smiley",
"supports": {
"html": false,
"multiple": false
},
"attributes": {
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | greybeard |
| Solution 2 | Marc |
