Gutenberg add a custom metabox to default blocks

Using filters we can modify the props and attributes of blocks. First we extend the attributes to include the new attribute: const { addFilter } = wp.hooks; // Register/add the new attribute. const addExtraAttribute = props => { const attributes = { …props.attributes, extra_attribute: { type: “string”, default: “default_value” } }; return { …props, attributes … Read more

Custom ACF block only outputs commented JSON to the DOM

I was facing this same issue, in my case the issue causing me this problem was silly, as usual. For those facing a similar issue, check your acf_register_block_type function: acf_register_block_type( array( ‘name’ => ‘theme-block-jobbz’, ‘title’ => __( ‘Title’, ‘client’ ), ‘enqueue_style’ => ‘template-parts/blocks/block_jobBz/block.css’, ‘render_template’ => ‘template-parts/blocks/block_jobBz/block.php’, ‘category’ => ‘Category’, ‘icon’ => ‘html’, ‘mode’ => ‘preview’, … Read more

Is there a way to grab the current value of the editor in Gutenburg/Classic WordPress editor? (Not the saved value of the post!)

If someone stumbles upon same issue I found a way to achieve what I wanted (I hope someone is helped by this). This is my solution: getEditedPostContent() contains the temporary post (modified) content: let old_content=””; if ($(‘textarea#content’).length >0) { old_content = $(‘textarea#content’).html(); } else { //”Gutenburg” style (>=WP 5.8) old_content = wp.data.select( ‘core/editor’ ).getCurrentPost().content; if … Read more