我们在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');
答案 0 :(得分:1)
请使用更新和删除类别检查更新的自定义帖子类型。
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);
希望这适合你。
答案 1 :(得分:0)
问题与您发布的代码无关。
我要删除 ' capability_type' register_post_type的参数和'能力' register_taxonomy调用,因为那些只是增加了一些没有价值的混乱,但除此之外没什么好。
确保以管理员身份登录,并检查是否可以修改其他分类,例如发布类别。 这应该可以帮助您找出问题的真正根源。