更新到WP 5.1.1后,“我的自定义分类法”不会显示在其指定的自定义帖子类型下。当我注释掉附加到这些自定义分类的自定义功能时,它们就会显示出来。我读到古腾堡编辑器需要将Rest API选项设置为true才能显示出来。我关闭了Gutenberg编辑器,但我尝试了Rest API中显示的自定义分类法false和true的两种方法。下面是带有注释掉的自定义功能的代码,它们在我以管理员身份登录时显示。但是,当我取出注释并为自定义分类法启用功能时,它们不会显示在管理员中指定的帖子类型下。
在更新之前,这一切都正常工作。当从WP 4.9.8转到WP 5.1.1时,现在他们不再出现了。我们需要这些自定义功能,因为我们有警报编辑器的自定义角色,它们限制了它们对这些分类法的使用。
此外,我们还将使用WebDev研究CPT UI,然后使用一个WebDev开发人员制作的插件,称为CPT UI功能。在更新之前,将这些插件一起使用效果很好。因此,在尝试进行一些调试时,我只需抓取代码并将其放入主题函数文件中,然后禁用这两个插件。
调试后,我发现了这个问题,只需注释出自定义分类法的自定义功能,然后它们就会显示出来。现在,我一直在搜索并尝试一切,以保持这些功能的启用,因为它们是必需的,但无法找出WP核心中发生了什么变化,导致它们现在无法显示。
任何帮助都将不胜感激!下面是我的自定义分类代码,其中包含注释掉的自定义功能,以便它们显示在分配的帖子类型下的管理中。
function cptui_register_my_taxes() {
/**
* Taxonomy: Categories.
*/
$labels = array(
"name" => __( "Categories", "custom-post-type-ui" ),
"singular_name" => __( "Category", "custom-post-type-ui" ),
);
$args = array(
"label" => __( "Categories", "custom-post-type-ui" ),
"labels" => $labels,
"public" => true,
"publicly_queryable" => true,
"hierarchical" => true,
"show_ui" => true,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"query_var" => true,
"rewrite" => array( \'slug\' => \'categories\', \'with_front\' => true, ),
"show_admin_column" => true,
"show_in_rest" => true,
"rest_base" => "categories",
"rest_controller_class" => "WP_REST_Terms_Controller",
"show_in_quick_edit" => false,
);
register_taxonomy( "categories", array( "texrail_post" ), $args );
/**
* Taxonomy: Route tags.
*/
$labels = array(
"name" => __( "Route tags", "custom-post-type-ui" ),
"singular_name" => __( "Route tag", "custom-post-type-ui" ),
);
$args = array(
"label" => __( "Route tags", "custom-post-type-ui" ),
"labels" => $labels,
"public" => true,
"publicly_queryable" => true,
"hierarchical" => true,
"show_ui" => true,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"query_var" => true,
"rewrite" => array( \'slug\' => \'route_tags\', \'with_front\' => true, ),
"show_admin_column" => true,
"show_in_rest" => true,
"rest_base" => "route_tags",
"rest_controller_class" => "WP_REST_Terms_Controller",
"show_in_quick_edit" => true,
// \'capabilities\' => array(
// \'manage_terms\' => \'manage_route_tags\',
// \'edit_terms\' => \'edit_route_tags\',
// \'delete_terms\' => \'delete_route_tags\',
// \'assign_terms\' => \'assign_route_tags\',
// )
);
register_taxonomy( "route_tags", array( "post", "_alerts_detours", "texrail_post" ), $args );
/**
* Taxonomy: GovDelivery Categories.
*/
$labels = array(
"name" => __( "GovDelivery Categories", "custom-post-type-ui" ),
"singular_name" => __( "GovDelivery Category", "custom-post-type-ui" ),
);
$args = array(
"label" => __( "GovDelivery Categories", "custom-post-type-ui" ),
"labels" => $labels,
"public" => true,
"publicly_queryable" => true,
"hierarchical" => true,
"show_ui" => true,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"query_var" => true,
"rewrite" => array( \'slug\' => \'govdelivery_categories\', \'with_front\' => true, ),
"show_admin_column" => true,
"show_in_rest" => true,
"rest_base" => "govdelivery_categories",
"rest_controller_class" => "WP_REST_Terms_Controller",
"show_in_quick_edit" => false,
// \'capabilities\' => array(
// \'manage_terms\' => \'manage_govdelivery_categories\',
// \'edit_terms\' => \'edit_govdelivery_categories\',
// \'delete_terms\' => \'delete_govdelivery_categories\',
// \'assign_terms\' => \'assign_govdelivery_categories\',
// )
);
register_taxonomy( "govdelivery_categories", array( "post", "page", "attachment", "portfolio-item", "wpdmpro", "_alerts_detours", "texrail_post" ), $args );
}
add_action( \'init\', \'cptui_register_my_taxes\' );