Notices in the Block Editor with multiple lines

The 3rd parameter for the function accepts a private option named __unstableHTML which if true, then enables HTML in the notice message/content: createNotice( ‘success’, ‘Post published.<br /> Line 2. Should work in WordPress 5.8.’, { __unstableHTML: true, // true = allows HTML; default false isDismissible: true, actions: [ … ], } ) However, in the … Read more

Gutenberg Button Border Radius Default

This should theoretically work by defining the initial value in theme.json as shown in these examples https://gist.github.com/skorasaurus/d50ea7eb79d664775418492e46cef021 and https://github.com/WordPress/theme-experiments/blob/304e6ef3d561f048c87d9bc27311328ae8197bae/tt1-blocks/theme.json#L276 however, the value is still unset when I tried it out in a theme and it appears they may have disabled it – https://github.com/WordPress/gutenberg/issues/29210

How do I dynamically render an InnerBlock inside a dynamic block?

Instead of removing the question, I’ll answer the question myself for those that seek to find the same answer. My InnerBlock was called counter-list.php, which causes a problem as I have a counter_list_render_callback function. When looping through all my blocks, it tries to find counter-list_render_callback which is an invalid function name and therefore fails to … Read more

How to set Gutenberg preferences programmatically with wp.data.dispatch?

This correctly shows true/false when the option for Reduce the interface is enabled/disabled through the GUI. Are you sure isFeatureActive( ‘reduceInterface’ ) worked? Because I looked at the source code (see wp-includes/js/dist/edit-post.js) and then I found out that the feature name is actually reducedUI and not reduceInterface. So try with reducedUI instead: let reduceInterface = … Read more

Register JS for block on frontend only

If you’re using WordPress 5.8 (e.g. v5.8.3), then I’m afraid the answer to this: I know that I can use is_admin() to check if it’s in the editor and not load a js file but I’m trying to see how it can be done with register_block_type(). .. is it can’t; not in WordPress 5.8. More … Read more

While creating Block Themes in WordPress, how can I query custom posts for an Archive view?

I found a solution for this. So for those of you who face a similar situation, here’s what I did (based on this solution : https://stackoverflow.com/questions/68871598/wordpress-query-loop-block-not-showing-custom-post-types) So basically the custom post type that I had created needed to have this argument while registering the post-type in functions.php ‘show_in_rest’ => true And then I just had … Read more