How can I add Block Style support to the core HTML block in Gutenberg?

Block Style Variations allow providing alternative styles to existing blocks using filters, as explained here. Here are some examples for your case using the server-side functions (php). You can either add the css style inline: register_block_style( ‘core/html’, array( ‘name’ => ‘full-width-video’, ‘label’ => __( ‘Full Width Video’ ), ‘inline_style’ => ‘.wp-block-html.is-style-full-width-video { width:100%; }’, ) … Read more

How to grab posts in Gutenberg Block?

You’ll need to use the REST API. You can access the latest posts by calling: wp.apiFetch( { path: ‘/wp/v2/posts’ } ).then( posts => { console.log( posts ); } ); Here is some more information on using the package – https://developer.wordpress.org/block-editor/packages/packages-api-fetch/

How to add a class to the element in a custom Gutenberg block

That documentation is for the base ButtonBlockAppender component in the @wordpress/block-editor package, and that component is exported with the name ButtonBlockerAppender (note the “Blocker” vs “Block”). But your code is actually using InnerBlocks.ButtonBlockAppender which is an enhanced version of that base ButtonBlockAppender component, and as of writing, that enhanced version does not include the className … Read more

Is there a way to set the gutenberg color palette outside the theme?

Yes, you have to use the init hook if you want to use add_theme_support from a plugin. I’ve tested the below code as a plugin and worked for me. <?php /* Plugin name: Add Color Palette */ function mytheme_setup_theme_supported_features() { add_theme_support(‘editor-color-palette’, array( array( ‘name’ => esc_attr__(‘Strong magenta’, ‘themeLangDomain’), ‘slug’ => ‘strong-magenta’, ‘color’ => ‘#a156b4’, ), … Read more

Initial help with official “create a block” tutorial

Glad that you managed to fix the 3rd issue (block validation failed), and as for the first and second issues, you can fix them by using useBlockProps in your block’s edit callback: // In src/index.js import { TextControl } from ‘@wordpress/components’; import { useBlockProps } from ‘@wordpress/block-editor’; export default function Edit( { attributes, className, setAttributes … Read more