wtyczki – Kiedy używam „show_in_rest”, JS zgłasza błąd
Stworzyłem niestandardowy typ postu w wtyczce i chcę użyć edytora bloków Gutenberga, ale kiedy ustawię show_in_rest
Do true
otrzymuję pusty biały ekran i ten komunikat o błędzie w konsoli:
function wppro_register_cpt() {
$labels = array(
'name' => _x( 'Portfolio Items', 'Post type general name', 'wp-portfolio-pro' ),
'singular_name' => _x( 'Portfolio Item', 'Post type singular name', 'wp-portfolio-pro' ),
'menu_name' => _x( 'Portfolio Items', 'Admin Menu text', 'wp-portfolio-pro' ),
'name_admin_bar' => _x( 'Portfolio Item', 'Add New on Toolbar', 'wp-portfolio-pro' ),
'add_new' => __( 'Add New', 'wp-portfolio-pro' ),
'add_new_item' => __( 'Add New Portfolio Item', 'wp-portfolio-pro' ),
'new_item' => __( 'New Portfolio Item', 'wp-portfolio-pro' ),
'edit_item' => __( 'Edit Portfolio Item', 'wp-portfolio-pro' ),
'view_item' => __( 'View Portfolio Item', 'wp-portfolio-pro' ),
'all_items' => __( 'All Portfolio Items', 'wp-portfolio-pro' ),
'search_items' => __( 'Search Portfolio Items', 'wp-portfolio-pro' ),
'parent_item_colon' => __( 'Parent Portfolio Items:', 'wp-portfolio-pro' ),
'not_found' => __( 'No portfolio items found.', 'wp-portfolio-pro' ),
'not_found_in_trash' => __( 'No portfolio items found in Trash.', 'wp-portfolio-pro' ),
'featured_image' => _x( 'Portfolio Item Cover Image', 'Overrides the “Featured Image” phrase for this post type. Added in 4.3', 'wp-portfolio-pro' ),
'set_featured_image' => _x( 'Set portfolio item image', 'Overrides the “Set featured image” phrase for this post type. Added in 4.3', 'wp-portfolio-pro' ),
'remove_featured_image' => _x( 'Remove portfolio item image', 'Overrides the “Remove featured image” phrase for this post type. Added in 4.3', 'wp-portfolio-pro' ),
'use_featured_image' => _x( 'Use as portfolio item image', 'Overrides the “Use as featured image” phrase for this post type. Added in 4.3', 'wp-portfolio-pro' ),
'archives' => _x( 'Portfolio item archives', 'The post type archive label used in nav menus. Default “Post Archives”. Added in 4.4', 'wp-portfolio-pro' ),
'insert_into_item' => _x( 'Insert into book', 'Overrides the “Insert into post”/”Insert into page” phrase (used when inserting media into a post). Added in 4.4', 'wp-portfolio-pro' ),
'uploaded_to_this_item' => _x( 'Uploaded to this portfolio item', 'Overrides the “Uploaded to this post”/”Uploaded to this page” phrase (used when viewing media attached to a post). Added in 4.4', 'wp-portfolio-pro' ),
'filter_items_list' => _x( 'Filter portfolio item', 'Screen reader text for the filter links heading on the post type listing screen. Default “Filter posts list”/”Filter pages list”. Added in 4.4', 'wp-portfolio-pro' ),
'items_list_navigation' => _x( 'Portfolio items list navigation', 'Screen reader text for the pagination heading on the post type listing screen. Default “Posts list navigation”/”Pages list navigation”. Added in 4.4', 'wp-portfolio-pro' ),
'items_list' => _x( 'Portfolio items list', 'Screen reader text for the items list heading on the post type listing screen. Default “Posts list”/”Pages list”. Added in 4.4', 'wp-portfolio-pro' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_in_menu' => true,
'show_in_rest' => true,
'rest_base' => 'portfolio_type',
'query_var' => true,
'rewrite' => array( 'slug' => 'wppro-portfolio' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => 11,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ),
'template' => 'single-wppro-portfolio.php',
);
register_post_type( 'wppro-portfolio', $args );
}
add_action( 'init', 'wppro_register_cpt' );