Custom Block + Custom Post Types = wp.blockEditor is undefined
-
Hello,
I made a few Custom Blocks and they work fine in posts and pages.
In custom post types I get the message the console that
wp.blockEditor is undefined
, and I can’t use the blocks.I think I am forgetting something when I declare my CPT, but can’t find what. I’ve also search the whole morning on the net and can’t find any reference to that issue :/
Here’s how I register the CPT and the Block:
function q_product_cpt() { if( function_exists('register_post_type') ) : $lables_cpt_product = array( 'name' => _x( 'Products', 'Post Sector General Name', 'q_product' ), 'singular_name' => _x( 'Product', 'Post Sector Singular Name', 'q_product' ), 'menu_name' => _x( 'Products', 'Admin Menu text', 'q_product' ), 'name_admin_bar' => _x( 'Product', 'Add New on Toolbar', 'q_product' ), 'add_new' => __( 'Add New', 'q_product' ), ... ); $args_cpt_product = array( 'label' => __( 'Products', 'q_product' ), 'description' => __( 'Products', 'q_product' ), 'labels' => $lables_cpt_product, 'supports' => array( 'title', 'custom-fields', 'editor', 'author', 'revisions', 'page-attributes' ), 'hierarchical' => false, 'public' => true, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'capability_type' => 'post', 'show_in_rest' => true, ); register_post_type( 'product', $args_cpt_product); endif; } add_action( 'init', 'q_product_cpt', 0 );
Here’s how I register the Block:
add_action( 'init', function() { wp_register_script('quasi-header-js', plugin_dir_url( __FILE__ ) . 'template-parts/blocks/quasi-header.js'); register_block_type('quasi/header', [ 'editor_script' => 'quasi-header-js', ]); }, 10);
And the actual error message in the console:
Uncaught TypeError: can't access property "RichText", wp.blockEditor is undefined
. I have this message even when I create an empty block and try to desctructure the RichText componentThank you!
- The topic ‘Custom Block + Custom Post Types = wp.blockEditor is undefined’ is closed to new replies.