我知道以前有人问过这个问题,我在互联网上搜索过,遇到过几个有类似问题的人,其中一些人有解决方案(显然,这些解决方案都不适合我)。以下是我注册自定义分类法的方式(为了简单起见,不包括标签):
register_taxonomy( \'location\', array( \'restaurant\' ), array(
\'labels\' => $labels,
\'public\' => true,
\'hierarchical\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'show_in_nav_menus\' => true,
\'show_admin_column\' => true,
\'show_in_rest\' => true, // Needed for tax to appear in Gutenberg editor.
\'rewrite\' => array( \'slug\' => \'location\' ),
));
我不知道它是否相关,但下面是我注册自定义类型帖子的方式(同样,为了简单起见,不包括标签):
$args = array(
\'labels\' => $labels,
\'description\' => __( \'Descripción.\', \'text-domain\' ),
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_rest\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'restaurant\' ),
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'taxonomies\' => array(\'location\'),
\'menu-icon\' => \'dashicons-format-gallery\',
\'menu_position\' => 5,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'comments\' )
);
register_post_type( \'restaurant\', $args );
Result in Gutenberg:包装:我通常可以在古腾堡之外使用分类法,我可以在古腾堡的文档面板中看到选项卡,但分类法没有显示在那里,而且Add new location 古腾堡内部的按钮不起作用
谢谢你的帮助