WordPress Gutenberg Columns block

All of the WP 5.x Core blocks are in a file called block-library.js. However, because the blocks all require a build step, you won’t be able to just copy the JS and start making edits. You’ll need to have Node.js and NPM installed. So, to get this all set up: Go to the Node JS … Read more

Gutenberg Reusable Block of WordPress

This is the way it worked for me: $post = get_post( $post_id ); if ( has_blocks( $post->post_content ) ) { $blocks = parse_blocks( $post->post_content ); foreach ( $blocks as $block ) { if ( isset( $block[‘attrs’][‘id’] ) ) { echo $block[‘attrs’][‘id’]; } elseif ( ‘core/block’ === $block[‘blockName’] ) { $block_content = parse_blocks( get_post( $block[‘attrs’][‘ref’] )->post_content … Read more

Change default colors in paragraph block settings

Rather than adjusting the default palette, you can define (and enforce) a custom palette. <?php // Add a custom palette add_action( ‘after_setup_theme’, ‘wpse_block_color_palette’ ); function wpse_block_color_palette() { add_theme_support( // Define the colors ‘editor-color-palette’, array( // First color – black array( ‘name’ => esc_html__( ‘Black’, ‘textdomain’ ), ‘slug’ => ‘black’, ‘color’ => ‘#2a2a2a’, ), // Second … Read more

Group block without inner wrapper

I did this in the function.php of my theme and it worked like a charm. Note: I am only missing the id, maybe someone can share a solution for that too. function custom_render_block_core_group ( string $block_content, array $block ): string { if ( $block[‘blockName’] === ‘core/group’ && !is_admin() && !wp_is_json_request() ) { $html=””; $tag = … Read more

Gutenberg default value not saved in json

When I set default values in my attributes for my Gutenberg blocks, the values can be consumed on the client, but it does not appear in the JSON data until I change the attribute with setAttributes. When we register a block type (think of it like a post type) which happens on each page load, … Read more