2 votes
Accepted

Gutenberg template lock but add/delete blocks programmatically

I couldn't find a standard way to do this, but as I commented, an easy way to do it is by using a state which will store either the initial template you set or the inner blocks (i.e. their names and ...
user avatar
  • 33k
2 votes
Accepted

Working with external library in gutenberg block

So the important thing to understand here is that while the block editor is React based, and can use React components, the data it saves is purely HTML. So your block will simply save the HTML output ...
user avatar
1 vote
Accepted

Update post meta custom field using block editor

how to update post meta in a custom field in response to a user interaction in the editor? editPost() can be used for that, but https://developer.wordpress.org/block-editor/reference-guides/block-api/...
user avatar
  • 33k
1 vote
Accepted

Gutenberg programmatically move block to position

You can use getBlockRootClientId() from the block editor's data store. E.g. wp.data.select( 'core/block-editor' ).getBlockRootClientId( clientId ) And here's a working example for you to see how it ...
user avatar
  • 33k
1 vote
Accepted

Getting taxonomies associated with a specified post type

Yes, you can pass a post type to getEntityRecords() and also getTaxonomies(), both using the same format which is an object of arguments: Using getEntityRecords(): wp.data.select( 'core' )....
user avatar
  • 33k
1 vote
Accepted

How to render a block from php template

Solved by manually inserting HTML into the template, Thanks.
user avatar
1 vote
Accepted

Custom Gutenberg block: access dom element via JavaScript

I need to access the dom element inside the editor. useRef can be used for that, but actually, instead of doing that, I would just apply the approach shown below to my edit() function :) https://...
user avatar
  • 33k
1 vote

Custom Gutenberg block: access dom element via JavaScript

The only semi-canonical solution which I am aware of would be to write the block to be dynamic, rendering that portion of the block with PHP function and using the Server Side Render component to ...
user avatar
  • 5,810
1 vote
Accepted

Display selected image in the MediaPlaceholder component

the interface remains unchanged, as if no image had been selected. How do I make the image I have selected appear in the editor? It remains unchanged because we actually need to manually add a ...
user avatar
  • 33k
1 vote

How to register two blocks in the same plugin

Add a subfolder in your-plugin/src with the block name Put all src files inside this folder Repeat 1 and 2 for other blocks that you want to add. At this moment, the src folder looks like this: Be ...
user avatar
  • 485
1 vote
Accepted

How do I assign a block template (.html) to a custom post type?

Classic and block(-based) themes both use the same template hierarchy, so for example in classic themes, we can add a template named single-<post type>.php which would be used as the default ...
user avatar
  • 33k
1 vote

Catching Gutenberg sidebar switch event

For everyone who is looking for a solution: The issue was that I wanted to use React. Component as I was sure it is required by WordPress. But Functional Component is also accepted, and in this case ...
user avatar
  • 11
1 vote

Possible to use @wordpress/create-block with multiple blocks?

I am using @wordpress/scripts v23.5.0 and it's already a built in feature. Please watch this video.
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible