How to use Javascript to get data from a WordPress form

This approach should work, Modify it for your use case. //JQuery Code jQuery( document ).on( ‘change’, ‘.from-this’, function( e ) { e.preventDefault(); jQuery( ‘.change-this’ ).text( this.value ); } ) HTML Code: <input type=”search” class=”from-this” /> <div class=”change-this”></div>

Add custom data attribute to every core Gutenberg Blocks

I found the solution: I removed addFilter(‘blocks.getSaveContent.extraProps’, ‘luxuryconcept/add-custom-props’, addCustomProps); as @TomJNowell recomended. I added the add_filter(‘render_block’, ‘theme_custom_add_custom_attributes’, 10, 2); PHP code to functions.php: So, here all the working code: JS: /** * * Extends Core Gutenberg Blocks functionalities * * @description Add data-delay and data-duration attributes to every Gutenberg Core Blocks * @package luxuryconcept * … Read more

Is It Possible to Use the Block Editor’s Notification Feature to Send Another Notification After the Post Is Saved?

Yes, but you have to do it Redux- way. Subscribe to post saving action (there are separate actions for save and auto-save) and dispatch a message using dispatch function. Edit: Inside blocks, there are better hooks to use, like useSelect. But, outside the block, in general block editor environmentm you have to use subscribe. In … Read more

useBlockProps() nests wrapper with class name inside block wrapper in the editor

I was bitten by this as well, and it caused me much frustration. I had exactly the same nested block duplication problem that you described above. I was able to solve this issue by specifying an apiVersion for my custom block. E.g.: registerBlockType(“custom-cafe-theme/custom-column”,{ apiVersion: 2, // or 3 title: “Custom Column”, attributes: { imgID: { … Read more

How to build BOTH non-block components and blocks present in the /src directory using @wordpress/scripts

I’m pasting the answer I got from a developer in the Gutenberg repository. Just add a webpack.config.js file at the root of your project with the following contents: const defaultConfig = require( ‘@wordpress/scripts/config/webpack.config’ ); module.exports = { …defaultConfig, entry: { …defaultConfig.entry(), index: ‘./src/index.js’, }, }; This will build all the blocks in /src/blocks/ folder and … Read more