WordPress Gutenberg blocks: Input fields are not editable

It turns out that in order to get to the value of an input field, you must point to it in your callback function, like so… const onChangeBorderWidth = newBorderWidth => { props.setAttributes( { borderWidth: newBorderWidth.target.value }) } This grabs the event’s input target value and assigns it to the correct attribute. HINT: You don’t … Read more

Block Editor: add an aria-label to an option inside a SelectControl

I agree with Nathan’s answer, but you can copy the source and create your own SelectControl component based on that source. Here’s an example, with basically just the aria-label addition: <option key={ `${ option.label }-${ option.value }-${ index }` } value={ option.value } disabled={ option.disabled } aria-label={ option.ariaLabel || ” } > { option.label } … Read more

Gutenberg: How to use output of php render_callback function in the block editors backend?

I think that you are missing the PHP registration of the block. The JS definition is all right, but you need to tell PHP that the block exists. Can you try to register your block in your plugin or function.php file? Here is an example https://developer.wordpress.org/block-editor/tutorials/block-tutorial/creating-dynamic-blocks/ <?php function simpletoc_toc_render_callback( $attributes, $content ) { return ‘This … Read more

WP 5.8 “Query Loop” block: where to place custom query?

Looking into render_block_core_post_template() we can see it calls build_query_vars_from_query_block() (previously named construct_wp_query_args) to setup the query arguments of WP_Query from the Query` block properties. From there I don’t see it supporting custom taxonomies for the secondary query … yet! Work-around-idea: For the Query Loop: add a search keyword for using custom taxonomies, e.g. :query-motor-electric: and … Read more

get selected categories or tags (using javascript) in GutenBerg?

To get the categories from inside the editor of a post you can make use of the following selectors: The categories the post has in the published version: wp.data.select(“core/editor”).getCurrentPostAttribute(“categories”) The current categories of the edit (for example if the user has selected a new category but hasn’t saved the post it will appear with this … Read more