首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >添加Gutenberg编辑器以编辑分类法(类别)页面

添加Gutenberg编辑器以编辑分类法(类别)页面
EN

WordPress Development用户
提问于 2022-12-13 09:07:13
回答 1查看 246关注 0票数 0

我创建了一个自定义post类型和自定义分类法。我需要允许编辑Gutenberg中的分类法页面,但是WordPress允许我只使用特定的字段。我怎样才能克服这个问题?

代码语言:javascript
复制
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');
EN

回答 1

WordPress Development用户

发布于 2022-12-16 01:42:46

您没有添加show in rest参数,在注册后设置为true。所有内容都必须启用REST,因为rest是块编辑器与WordPress的rest :)通信的方式。

票数 1
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/412067

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档