wordpress - 无法删除或编辑类别 - Wordpress
问题描述
我们发现我们的 wordpress 系统存在一个奇怪的错误。我们为一种自定义帖子类型创建了自定义类别。在后端,类别不可编辑或删除。以前有人遇到过这个问题吗?
没有安装特殊的插件,之前也没有做任何特别的事情......
希望各位大侠帮忙!谢谢!
自定义帖子类型代码(我们已经尝试使用根本不起作用的功能来解决它)
function bm_custom_post_type()
{
$labels = array(
'name' => __( 'Anwälte' ),
'singular_name' => __( 'Anwalt' ),
'add_new' => __( 'Anwalt hinzufügen' ),
'add_new_item' => __( 'Anwalt hinzufügen' ),
'edit_item' => __( 'Anwalt bearbeiten' ),
'new_item' => __( 'Anwalt hinzufügen' ),
'view_item' => __( 'Anwalt ansehen' ),
'search_items' => __( 'Anwalt durchsuchen' ),
'not_found' => __( 'Keinen Anwalt gefunden...' ),
'not_found_in_trash' => __( 'Keinen Anwalt im Papierkorb gefunden.' ),
'parent_item_colon' => ''
);
$fields = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'capability_type' => 'post',
'menu_icon' => 'dashicons-businessman',
'hierarchical' => false,
'menu_position' => null,
'rewrite' => array( 'slug' => 'anwaelte' ),
'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes', 'revisions' )
);
register_post_type('anwaelte', $fields);
register_taxonomy(
'expertise',
array( 'anwaelte', 'page' ),
array(
'capabilities' => array(
'manage_terms' => 'manage_categories',
'edit_terms' => 'manage_categories',
'delete_terms' => 'manage_categories',
'assign_terms' => 'edit_posts'
),
'label' => __( 'Expertise' ),
'hierarchical' => true,
'rewrite' => array('slug' => 'tax-expertise'),
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
)
);
register_taxonomy(
'rechtsgebiete',
array( 'anwaelte' ),
array(
'capabilities' => array(
'manage_terms' => 'manage_categories',
'edit_terms' => 'manage_categories',
'delete_terms' => 'manage_categories',
'assign_terms' => 'edit_posts'
),
'hierarchical' => true,
'label' => __( 'Rechtsgebiete' ),
'rewrite' => array('slug' => 'tax-rechtsgebiete'),
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
)
);
}
add_action('init', 'bm_custom_post_type');
解决方案
请使用更新和删除类别检查更新的自定义帖子类型。
function bm_custom_post_type()
{
$labels = array(
'name' => __( 'Anwälte' ),
'singular_name' => __( 'Anwalt' ),
'add_new' => __( 'Anwalt hinzufügen' ),
'add_new_item' => __( 'Anwalt hinzufügen' ),
'edit_item' => __( 'Anwalt bearbeiten' ),
'new_item' => __( 'Anwalt hinzufügen' ),
'view_item' => __( 'Anwalt ansehen' ),
'search_items' => __( 'Anwalt durchsuchen' ),
'not_found' => __( 'Keinen Anwalt gefunden...' ),
'not_found_in_trash' => __( 'Keinen Anwalt im Papierkorb gefunden.' ),
'parent_item_colon' => ''
);
$args = array(
'label' => __( 'Anwälte', 'twentythirteen' ),
'description' => __( 'Anwälte', 'twentythirteen' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_icon' => 'dashicons-businessman',
'menu_position' => 5,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
// This is where we add taxonomies to our CPT
'taxonomies' => array( 'category' ),
);
// Registering your Custom Post Type
register_post_type( 'anwaelte', $args );
}
add_action('init', 'bm_custom_post_type',0);
希望这对你有用。
推荐阅读
- reactjs - 通过使用表单数据将 base64 数据 uri 转换为文件对象,从本地目录(不上传)保存图像
- javascript - 在 Div 中裁剪文本(具有多个
和
- )
- windows - Lua 5.4 源代码包含在 c++Builder 10.1 中不太正确
- javascript - Javascript 承诺 + useState + firebase onSnapshot
- javascript - 在 Redux 中分派多个 reducer 和 case 是一个好习惯吗?
- android - 如何将不同的主题应用于单一活动方法
- apache-spark - Spark 流式传输是否需要 HDFS 和 Kafka
- tiled - 如何在对象层中插入多个图块?
- javascript - 使用 matchMedia,调整窗口大小以修复响应式浏览边缘情况
- python - 虽然猜谜游戏中的函数不断循环,python