首页 > 解决方案 > 无法删除或编辑类别 - 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');

标签: wordpressbackendcategories

解决方案


请使用更新和删除类​​别检查更新的自定义帖子类型。

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);

希望这对你有用。


推荐阅读