New answers tagged

0 votes

Code block treats characters not being escaped

Sorry for bothering you all, I found out there is an option in the syntax highlighter plugin that I am using "Crayon Syntax Highlighter" and by checking the "decode HTML entities in ...
user avatar
  • 101
0 votes

Can this react script be optimized? How to make it faster

Of course it never changes, because you told it that it never changes: // Selected page list const { initialSelectedPages, selectedPagesResolved} = useSelect( ( select) =&...
user avatar
  • 53.3k
0 votes

Wordpress - Get Posts with Category data

Sorry for the late answer, It helps me a bit thanks @antti, so i couldn't get the Category Name out of the post without wp_get_post_categories() i try to change the way i get the posts from get_posts()...
user avatar
  • 3
1 vote

How to change this WP logo and posts url in block editor?

You can change the logo in the block editor or site editor using the SlotFill system. Have a look at the this example code taken from https://developer.wordpress.org/block-editor/reference-guides/...
user avatar
  • 3,398
0 votes

Add Custom Alignment Option to Wordpress Blocks/Gutenberg

Today i have same task for add extra alignment but gutarnberg not provide any type of functionality for extending core column you can set max width settings for wide width like this in json file in ...
user avatar
1 vote

Gutenberg on block move

I don't know if there's an event or Gutenberg hook like blockMove or blockIndexChange, but you can use subscribe() from the @wordpress/data package to listen to the block index changes. Working ...
user avatar
  • 33.1k
0 votes

Can you disable typography panels for just the paragraph block?

Aug 2022 Using theme.json The easier and most convenient way is to use theme.json. use false for all the properties. Remove for only paragraph blocks { "version": 2, "settings&...
user avatar
  • 143
0 votes

Removing panels (meta boxes) in the Block Editor

I found a faster solution, you can just add this functions in php. This for example disables tags: add_action('admin_head', 'webroom_add_css_js_to_admin'); function webroom_add_css_js_to_admin() { ...
user avatar
0 votes

Blocks - any way to have editor honor width percentages on child blocks?

Leaving this open in case anyone has a cleaner answer, but just wanted to capture what I ended up going with for the time being. Looking at how Wordpress handles some of their native blocks, it looks ...
user avatar
0 votes

How do I replace a render_callback function for a block?

Try This one on your functions.php or main Plugin file add_filter('register_block_type_args', function ($settings, $name) { if ($name == 'demo/content-with-sidebar') { $settings['...
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
  • 33.1k
0 votes
Accepted

Can you disable typography panels for just the paragraph block?

yes you can remove those options via theme.json but it has to be done block by block. This might help you (not my course): https://wpdevelopment.courses/articles/block-editor-typography-settings/#...
user avatar
0 votes

Basic use of useState

This works. I'm not sure why, but separating the Player component in other component I can update the component from the button callback. Just to explain the use of useState here: the videoId ...
user avatar
  • 485
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
  • 33.1k
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
  • 33.1k
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
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

How to render a block from php template

Solved by manually inserting HTML into the template, Thanks.
user avatar
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
  • 33.1k
0 votes

How to set defaults for Border controls in custom block

I'm not sure if this is the right way for setting default values. But I'm able to set the default border values like this: registerBlockType( 'block-name', { ... supports: { ...
user avatar
0 votes

Extend core block in Gutenberg

Long time ago... :) In the meantime I wrote a little tutorial for extending Gutenberg blocks: Extending Gutenberg blocks
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
  • 33.1k
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,835
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
  • 33.1k
0 votes

Modify custom block plugin without losing content

To prevent this kind of error whenever you change the block structure, I suggest using Dynamic Block instead. You can read more about it here.
user avatar
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

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 votes

Block pattern conflict with custom block

After more debugging, I finally fixed it. The solution was to match the block markup with the pattern markup. So if my block has style="--swiper-pagination-color: undefined" the same style ...
user avatar
  • 113
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
  • 33.1k
0 votes
Accepted

Problem extending a core block

SOLUTION After days of unsuccessful attempts, having tried all kinds of solutions, I decided to remove any reference to the method __experimentalGetElementClassName and solved the problem.
user avatar
0 votes

WordPress Gutenberg react make import of __experimentalUseInnerBlocksProps which is no more experimetal

I used the logic from the accepted answer, which works great. But I implemented it a little differently. I import useInnerBlocksProps as nonExperimentalUseInnerBlocksProps. This way, I can keep using ...
user avatar
  • 460
-1 votes

Add a hyperlink to a group block?

Using JavaScript I see being the only practical way for the time being. If we create a CSS class called outer-block-link and add it to a link, on page load, it could scan the page and for each link or ...
user avatar
0 votes

How to remove the old "Custom CSS" from customizer after the theme has been migrated to Gutenberg FSE

The CSS is stored in the Custom Post Type 'custom_css' and there will be reference to it serialized in the options table with the option_name 'theme_mods_yourthemename' and it will look something like ...
user avatar
0 votes
Accepted

Wordpress - Get Posts with Category data

One major issue that I see in your code is the nested foreach loop. If a post has more than one category then the post would be rendered again and again for each category. Another thing is that using ...
user avatar

Top 50 recent answers are included