Last active
April 28, 2023 18:18
-
-
Save dcooney/6be6abd45be04105a3de5628f9bc1f7b to your computer and use it in GitHub Desktop.
Gutenberg Functions and Hooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Select a block. | |
wp.data.dispatch("core/block-editor").selectBlock(clientId); | |
// Update block attributes. | |
wp.data.dispatch("core/block-editor").updateBlockAttributes(clientId, { content: "<p>this is the new content</p>"}); | |
// Replace a block. | |
wp.data.dispatch("core/block-editor").replaceBlock( | |
clientId, | |
wp.blocks.createBlock("core/image", { | |
id: attachment_id, | |
url: attachment_url, | |
alt: "This is the Alt Text", | |
caption: "This is the Caption", | |
}) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment