创建提要栏的Gutenberg示例https://wordpress.org/gutenberg/handbook/designers-developers/developers/tutorials/plugin-sidebar-0/不保留框中输入的内容。刷新页面后,输入的内容消失,文本框为空。我想这是某种休息问题吧?
我刚刚检查过,更新post时,元字段是通过post请求发送的,因此这不是REST问题:
{“meta”:{“sidebar\\u plugin\\u meta\\u block\\u field”:“Jozica1”},“content”:“…等等
PHP代码:
add_action( \'init\', function () {
if (is_admin()) {
wp_register_script( \'gmk-sidebar-js\', get_template_directory_uri() . \'/js/sidebar-panel.js\',
[ \'wp-plugins\', \'wp-edit-post\', \'wp-element\', \'wp-components\', \'wp-data\' ]
);
wp_register_style( \'gmk-sidebar-style\', get_template_directory_uri() . \'/css/admin-guten-sidebar.css\' );
register_post_meta( \'\', \'sidebar_plugin_meta_block_field\', array(
\'show_in_rest\' => true,
\'single\' => true,
\'type\' => \'string\',
) );
}
} );