Gutenberg Editor: dynamicaly change slug field with an ACF field

I’ve found a way to dynamicaly change the slug field with the short title custom field. jQuery(document).ready(() => { const acfField = ‘field_61f8bacf53dc5’; const inputShortTitle = document.getElementById(‘acf-‘ + acfField); const slugify = (str) => { return str.toLowerCase().replace(/ /g, ‘-‘) .replace(/-+/g, ‘-‘).replace(/[^\w-]+/g, ”); } const updateSlug = () => { wp.data.dispatch(‘core/editor’).editPost({slug: slugify(inputShortTitle.value)}); } if (inputShortTitle !== … Read more

How to remove specific panels in the editor (Gutenberg) when editing a block (via right panel)?

Removing specific panels or features for a block is done on a per block basis using various hooks (https://github.com/WordPress/gutenberg/issues/15450#issuecomment-635255936) Update (August 2021) Removing specific panels (that would allow for customization of a block) can now be done through the theme.json aka global settings and styles which allows you to customize settings (colors, typography, etc) for … Read more

Best practices for CPT without using an editor [closed]

I have used the custom block option quite extensively. I enable the editor for the custom post type, but use a custom template with template_lock set to true: ‘template’ => array( array(‘pb/custom-block-name’), ), ‘template_lock’ => true Then I use the allowed_block_types_all filter to only allow that custom block for the post type: function pb_allowed_block_types($allowed_block_types, $block_editor_context) … Read more

Gutenberg translation is not working

I’ve spent all day debugging this issue, and by looking at the code I can guess we shared the same problems: assuming $script_handle is CUSTOM-block-ref-holder, the PHP file is almost correct. wp_set_script_translations needs the full path to work. In your case, although you probably need to adjust for your path, it should be something like … Read more