How to change the selected Template using javascript?

You are already using the correct action, i.e. wp.data.dispatch( ‘core/editor’ ).editPost(), however, you should instead change the property named template. I.e. wp.data.dispatch( ‘core/editor’ ).editPost( { template: ‘article.php’ } ) Yes, _wp_page_template is the meta key in the database, but in the REST API, a property named template exists in place of direct access on that … Read more

WordPress custom Block showing error in Posts editor but working in Pages editor

This should work: <?php if ( is_user_logged_in() ) { echo “This isn’t editable in here”; } else { include get_template_directory() . ‘/template-parts/blocks/form/from/functions.php’; if ( ! isset( $_POST[‘firstFormDisplayed’] ) ) { // we haven’t yet displayed the form asking for numbers, so do that now. displayFirstForm(); } else { // we’ve got the numbers, but not … Read more

Removing Default Panels From Gutenberg Document Setting Panel (sidebar)

import { store as editPostStore } from ‘@wordpress/edit-post’; Is not the same as const { editPostStore } = wp.editPost.store; In the first line store is editPostStore, but in your second line editPostStore is a property of store, but it doesn’t exist. The correct syntax is const editPostStore = wp.editPost.store; Or const { store: editPostStore } … Read more

How do I load styles into the block editor admin screen?

The same way you do it for the classic editor, there’s a dedicated API for this: https://developer.wordpress.org/reference/functions/add_editor_style/ https://developer.wordpress.org/reference/functions/add_editor_style/#comment-1171: /** * Registers an editor stylesheet for the theme. */ function wpdocs_theme_add_editor_styles() { add_editor_style( ‘custom-editor-style.css’ ); } add_action( ‘admin_init’, ‘wpdocs_theme_add_editor_styles’ ); The block editor will read in your stylesheet, modify the rules so that they only apply … Read more