Get post ancestors in the Block Editor

August 20, 2022 Update: For completeness, I added a JavaScript/Gutenberg solution which does what the findParent() function in question tries to do, i.e. find the top ancestor. You can find the code below the “Original Answer” section. Original Answer The block editor doesn’t (currently) have a function equivalent to get_post_ancestors(), and yes you could create … Read more

Block validation failed

As Tom pointed out, without the actual code of the block (specifically the save function) it is impossible to tell you exactly what the issue is. That said, if you compare what was generated by the save function and what was in the post body, you’ll see that there is content missing in each of … Read more

Add media dynamically on gutenberg block

You can set the multiple and gallery props to {true} which enables to select multiple images and make a gallery. More information in the GitHub readme: https://github.com/WordPress/gutenberg/tree/master/packages/block-editor/src/components/media-upload

Multiple checkboxes Gutenberg control

Use this code $.each(data, function (c, fields) { checkboxes.push( el( CheckboxControl, { key: fields.value, label: fields.label, name: ‘myCheckbox[]’, checked: props.attributes.myCheckbox.indexOf(fields.value) > -1, onChange: function( val ) { let data = props.attributes.myCheckbox; if (val) { if (data.indexOf(fields.value) === -1) { data.push(fields.value); } } else { data = props.attributes.myCheckbox.filter((v) => v !== fields.value); } props.setAttributes({ myCheckbox: data … Read more