When using apiVersion: 2
you must use the new useBlockProps
hook to implement standard block behavior for your custom block. In your case you would “tell” the editor to treat your <img>
as a block wrapper. This needs to be implemented in Edit
and in Save
and is explained here in detail: https://make.wordpress.org/core/2020/11/18/block-api-version-2/
Alternatively you could leave out apiVersion: 2
and try again. The editor will automatically add a wrapper element to your block enabling standard block behaviour.
Hope this helps.
Related Posts:
- Proper, exhaustive documentation for wp.editor etc
- Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
- Add colors to existing color palette without replacing it
- Can you filter posts by meta key with the getEntitityRecords selector?
- WP Gutenberg custom block – generate theme colors from SASS and use them in the inspector and php callback
- create blocks programmtically on theme activation
- Can I customize any WordPress parent block-based theme template files by child theme like a parent classic theme?
- How to support Lazy Loading Assets in a WordPress Theme?
- WordPress Gutenberg Theme: Structure, Hierarchy and Custom Templates
- Gutenberg Reusable Block as part of WordPress Theme page
- Custom button block doesn’t work
- How to float an image in Gutenberg
- Gutenberg – editor-font-sizes in functions not working
- Which file handles the block latest posts, I want to examine excerpt handling
- create-guten-block in wordpress theme?
- What VSCode extensions are there for working with block themes? [closed]
- What is the “correct” way to add hooks or similar PHP behavior to a blocktheme?
- Not able to select width of blocks inside of cover block
- How to check if a WordPress core block is active in sidebar
- gutenberg add classes to list items
- How do you replace content generated by custom fields with custom blocks in Block Editor?
- Custom Blocks as part of a theme
- How to wrap all titles generated by Gutenberg “Heading” block with tag
- How to add InnerBlock multiple times in the same block
- Moving post title down the page / Removing a block from a post
- HTML block gutenberg templates
- Gutenberg theme development: how to add “headers” option under styles > colors > elements?
- Change default rel attributes for Image Block & Button Block
- How to update mark-up of a gallery block in a custom theme?
- Auto focus RichText field
- How to create nested array attribute
- Show popover with url and option to open in new window
- How to Modify WP_Includes/blocks/latest_posts.php
- How to render block editor in wp-admin custom pages programmatically
- Social-Link block not loading html on page with custom theme
- How to diagnose wp-env environment problem
- Attribute form NumberControl doesn’t update when I update page before it lose its focus
- WP Gutenberg custom block – generate theme colors from SASS and use them in the inspector and php callback
- Posts Page shows Classic Editor interface not Gutenberg
- How can I include custom Gutenberg Blocks in a theme?
- Block validation failed for `core/pullquote` after adding theme support for editor-color-palette
- Is there a way to add classes to a page when using a Gutenberg reusable block as page layout?
- Correct way to make a custom block theme responsive
- Multiple content areas with Gutenberg – Transparent areas mid content
- Insert gutenberg blocks into template
- Template for posts of category in block theme?
- Can’t select my block by clicking on it on apiVersion – but using blockProps
- How can I use pre declared blocks in a php file?
- Is there any filter or action hook to remove layout classes from appearing in my templates?
- Full site editing templates folder vs block-templates
- How to set the margin on an innerBlock in a block variation?
- Align images to the left of the content
- Image and font support missing in editor when deploying theme remotely
- Why is my Toggle field not showing in Gutenberg?
- When trying to run build script with gutenberg (with SVG import) – Error: Plugin name should be specified
- Block to show posts from same category
- How To extend WP_Customize_Control
- How to show a custom meta box on the “Quick Edit” screen?
- What can I hook into after_setup_theme?
- Removing all classes from nav_menu except current-menu-item and current-menu-parent
- Can’t edit style.css in subdirectory of my theme?
- Best practice for including plugins as part of a theme?
- query posts in wordpress
- How to handle theme customization and sass variables
- wp_enqueue_scripts not called on search page?
- Add tinymce to widget textareas
- Custom Nav Walker to show siblings and children of current branch?
- What is the best way to handle multiple calls to get_template_directory_uri() and similar functions?
- Child themes: disabling the parent
- Is there a filter for enqueue script to strip the type=”text/javascript” property
- Fancy-box Esay wordpress plugin fails to work on Multilingual site
- Should I use function_exists() and/or add_action() in theme development?
- Bold letters inside excerpt [closed]
- Set default featured image for terms of a custom taxonomy
- Timber: Get single image from media library with all attributes
- page.php dependent sites are not working in custom woocommerce theme
- Why wp_nav_menu() doesnt show the proper meny when invoked two consecutive times?
- ACF Pro make URL Linked in Custom Template [closed]
- Can’t use admin_enqueue_scripts or wp_enqueue_script
- How is the `get_sidebar` function meant to be used to call a 2nd sidebar?
- How to find and remove unnecessary theme scripts? [closed]
- Theme logo metadata into template file
- Setting conditional background image from meta value
- How to Emulate Default Navigation Menu Behaviour in a Custom Theme?
- How can I run code in functions.php when switch_theme() is called?
- Strict Folder and File Permissions for WordPress Themes Folder
- Default customizer colors aren’t displayed outside of the preview
- More HTML elements variety in visual editor
- How allow users to select the theme color?
- hide/show a div in wordpress
- Create new sidebars trough admin post/page metabox
- How one category can have different fields?
- How to add script properly for certain post?
- How do child themes work?
- Why WordPress gets old templates code instead of the last updated ones
- adding navigation to genesis themes
- Checking conditionals
- including post-specific feed without full wp_head()
- Upgrade to WP 3.2/ and Server to php5 breaks theme? [closed]
- What matters should I care to make my theme SEO friendly? [closed]