How to set defaults for Border controls in custom block
How to set defaults for Border controls in custom block
How to set defaults for Border controls in custom block
Remove a component fill from a Block Editor panel
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
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
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
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
You can add a 2 column block layout where 1 block takes up 2 thirds in the block editor using the UI. Adding CSS classes to achieve this is highly unusual and unnecessary When you add a column block it asks you: Resulting in column blocks spaced for thirds: Each block has a percentage width … Read more
You could use a block template. For any given post type, you can set up a block template which adds blocks to the Editor whenever you create a new post of that type. These templates have an option called template_lock which you can set to all which means that users cannot add, move, or delete … Read more
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
Your block has no attributes. It does however have atrributes. Change atrributes to attributes and things should make more sense.