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

WP Gutenberg – How to parse simple images?

When you return $post->post_content you’re returning the raw content from the database. Things like shortcodes, dynamic blocks and responsive image markup will not exist in the content. To prepare content for output you need to run it through the the_content filter: ‘content’ => apply_filters( ‘the_content’, $post->post_content ), That being said, there is already an endpoint … Read more

Use a custom block inside another custom block

Finally,I have found a solution. I can pass my custom block to the InnerBlocks inside a template prop. const TEMPLATE = [ [ “core/columns”, {}, [ [ “core/column”, {}, [[“custom/Block A”, { url: “this is a url” }]], ], [ “core/column”, {}, [[“core/paragraph”, { placeholder: “Enter side content…” }]], ], ], ], ]; <InnerBlocks template={TEMPLATE} … Read more