我创建了一个自定义post类型和自定义分类法。我需要允许编辑Gutenberg中的分类法页面,但是WordPress允许我只使用特定的字段。我怎样才能克服这个问题?
function first_post_type()
{
$args = array(
'labels' => array(
'name' => 'Stock',
'singular_name' => 'Unit',
),
'hierachical' => true,
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-schedule',
'supports' => array('title', 'editor', 'thumbnail', 'custom-fields'),
//'rewrite' => array ('slug' => 'products'),
);
register_post_type('products', $args);
}
add_action('init', 'first_post_type');
function first_post_taxonomy()
{
$args = array(
'labels' => array(
'name' => 'Categories',
'singular_name' => 'Category',
),
'public' => true,
'hierarchical' => true,
'supports' => array('title', 'editor', 'thumbnail', 'custom-fields'),
'show_ui' => true,
'show_admin_column' => true,
'show_in_rest' => true,
'query_var' => true,
);
register_taxonomy('units', array('products'), $args);
}
add_action('init', 'first_post_taxonomy');发布于 2022-12-16 01:42:46
您没有添加show in rest参数,在注册后设置为true。所有内容都必须启用REST,因为rest是块编辑器与WordPress的rest :)通信的方式。
https://wordpress.stackexchange.com/questions/412067
复制相似问题