Reputation: 93
we have detected a strange bug with our wordpress-system. We have created custom categories for one custom post type. In the backend the categories are not editable or deletable. Does someone had this issue before?
No special Plugins were installed and nothing special were done before...
Hope you guys can help out! Thank you!
Custom Post Type Code (we have already tried to solve it with the capabilities which won't work at all)
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');
Upvotes: 2
Views: 170
Reputation: 167
Problem is not related to the code you've posted.
I'd remove 'capability_type' argument of register_post_type and 'capabilities' of register_taxonomy calls since those just adds a bit more mess without value, but other than that it's fine.
Make sure you are logged in as Administrator, and check if you can modify other taxonomies, like post categories. That should help you to identify the real source of problem.
Upvotes: 0
Reputation: 6555
Please check updated custom post type with update and delete category.
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);
Hope this works for you.
Upvotes: 1