Wordpress:功能自定义帖子类型delete_post不起作用

轻率的

我在Wordpress中使用“自定义帖子类型”和“成员”插件。

我的问题是在我的自定义帖子类型中,我无法删除帖子,移动到回收站的链接不存在:(

这是我的代码:

'capabilities' => array(
  'edit_post'          => 'edit_entrada_tallers_activitats_grups', 
  'read_post'          => 'read_entrada_tallers_activitats_grups', 
  'delete_post'        => 'delete_entrada_tallers_activitats_grups', 
  'delete_posts'        => 'delete_entradas_tallers_activitats_grups',
  'delete_others_posts' => 'delete_others_entradas_tallers_activitats_grups',
  'delete_published_posts' => 'delete_published_entradas_tallers_activitats_grups',
  'edit_posts'         => 'edit_entrada_tallers_activitats_grups', 
  'edit_others_posts'  => 'edit_others_entrada_tallers_activitats_grups', 
  'publish_posts'      => 'publish_entrada_tallers_activitats_grups',       
  'read_private_posts' => 'read_private_entrada_tallers_activitats_grups', 
  'create_posts'       => 'edit_create_entrada_tallers_activitats_grups', 

它出现在“编辑功能”页面插件中,并且我选中了以下复选框:

  • delete_entradas_tallers_activitats_grups(delete_posts
  • delete_others_entradas_tallers_activitats_grups(delete_others_posts
  • delete_published_entradas_tallers_activitats_grups(delete_published_posts

但是不是“ delete_entrada_tallers_activitats_grups”(delete_post),也许这是问题所在,但我不知道如何解决...。

更新完整代码

function my_custom_post_tallers_grup() {
  $labels = array(
    'name'               => _x( 'Aquí t’escoltem', 'post type general name' ),
    'singular_name'      => _x( 'Taller i activitat per a grups', 'post type singular name' ),
    'add_new'            => _x( 'Afegeix', 'oferta' ),
    'add_new_item'       => __( 'Afegeix nova entrada' ),
    'edit_item'          => __( 'Editar' ),
    'new_item'           => __( 'Nova entrada' ),
    'all_items'          => __( 'Totes les entrades' ),
    'view_item'          => __( 'Veure entrada' ),
    'search_items'       => __( 'Cercar entrades' ),
    'not_found'          => __( 'No s\'ha trobat.' ),
    'not_found_in_trash' => __( 'No s\'ha trobat a la paperera' ), 
    'parent_item_colon'  => '',
    'menu_name'          => 'Aquí t’escoltem'
  );
  $args = array(
    'labels'        => $labels,
    'description' => 'Entrades d\'aqui t'escoltem', 
    'publicly_queryable' => true,
    'exclude_from_search' => false,
    'show_ui' => true,
    'public'        => true,
    'query_var' => true,
    'menu_position' => 3,
    'rewrite'   => array( 'slug' => 'tallers-i-activitats-per-a-grups', 'with_front' => false ),
    'supports'      => array( 'title', 'editor', 'sticky', 'thumbnail' ),
    'has_archive'   => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'capabilities' => array(
  'edit_post'          => 'edit_entrada_tallers_activitats_grups', 
  'read_post'          => 'read_entrada_tallers_activitats_grups', 
  'delete_post'        => 'delete_entrada_tallers_activitats_grups', 
  'delete_posts'        => 'delete_entradas_tallers_activitats_grups',
  'delete_others_posts' => 'delete_others_entradas_tallers_activitats_grups',
  'delete_published_posts' => 'delete_published_entradas_tallers_activitats_grups',
  'edit_posts'         => 'edit_entrada_tallers_activitats_grups', 
  'edit_others_posts'  => 'edit_others_entrada_tallers_activitats_grups', 
  'publish_posts'      => 'publish_entrada_tallers_activitats_grups',       
  'read_private_posts' => 'read_private_entrada_tallers_activitats_grups', 
  'create_posts'       => 'edit_create_entrada_tallers_activitats_grups', 
)
  );
  register_post_type( 'tallers_grup', $args );      
    register_taxonomy_for_object_type( 'category', 'tallers_grup' );
}
add_action( 'init', 'my_custom_post_tallers_grup' );
火雾

我在您的代码中发现了一些错误,因此我重写了您的完整代码。

注意:您可以在您的“语言”上进行翻译

function tallers_grup_post_type() {

// Set UI labels for Custom Post Type 
    $labels = array(
        'name'                => _x( 'Aquí t’escoltem',  'tallers_grup' ),
        'singular_name'       => _x( 'Taller i activitat per a grups', 'tallers_grup' ),
        'menu_name'           => __( 'Aquí t’escoltem', 'tallers_grup' ),
        'parent_item_colon'   => __( 'Parent Aquí t’escoltem', 'tallers_grup' ),
        'all_items'           => __( 'Totes les entrades', 'tallers_grup' ),
        'view_item'           => __( 'Veure', 'tallers_grup' ),
        'add_new_item'        => __( 'Afegeix nova entrada', 'tallers_grup' ),
        'add_new'             => __( 'Afegeix', 'tallers_grup' ),
        'edit_item'           => __( 'Editar', 'tallers_grup' ),
        'update_item'         => __( 'Actualizar', 'tallers_grup' ),
        'search_items'        => __( 'Buscar ', 'tallers_grup' ),
        'not_found'           => __( 'Extraviado', 'tallers_grup' ),
        'not_found_in_trash'  => __( 'No encontrado en la basura', 'tallers_grup' ),
    );


    $capabilities = array(
                 'publish_posts'        => 'publish_tallers_grup',
                 'edit_posts'           => 'edit_tallers_grup',
                 'edit_others_posts'    => 'edit_others_tallers_grup',
                 'delete_posts'         => 'delete_tallers_grup',
                 'delete_others_posts'  => 'delete_others_tallers_grup',
                 'read_private_posts'   => 'read_private_tallers_grup',
                 'edit_post'            => 'edit_tallers_grup',
                 'delete_post'          => 'delete_tallers_grup',
                 'read_post'            => 'read_tallers_grup',
                 'create_posts'         => 'edit_create_tallers_grup',
                );


// Set other options for Custom Post Type
    $args = array(
        'label'               => __( 'Tallers grup', 'tallers_grup' ),
        'description'         => __( 'Entrades d\'aqui t\'escoltem', 'tallers_grup' ),
        'labels'              => $labels,
        'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'custom-fields', ),
        'hierarchical'        => false,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'menu_icon'           => 'dashicons-download',
        'can_export'          => true,
        'has_archive'         => true,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'capability_type'     => 'tallers_grup',
        'capabilities'        => $capabilities,
    );
// Registering your Custom Post Type
    register_post_type( 'tallers_grup', $args );
}
add_action( 'init', 'tallers_grup_post_type', 0 );
///********************** CUSTOM ROLE *****************************/
 add_role('dictionary_entry_author', 'Grup de tallers de dirigents', array (
                 'publish_dictionary_entry' => true,
                 'edit_dictionary_entry' => true,
                 'edit_others_dictionary_entry' => true,
                 'delete_dictionary_entry' => true,
                 'delete_others_dictionary_entry' => true,
                 'read_private_dictionary_entry' => true,
                 'edit_dictionary_entry' => true,
                 'delete_dictionary_entry' => true,
                 'read_dictionary_entry' => true,
                 // more standard capabilities here
                'read' => true,
    )
);
//==============================================
add_action( 'init', 'create_tallers_grup_taxonomies', 0 );

function create_tallers_grup_taxonomies() {
    // Add new taxonomy, make it hierarchical (like categories)
    $labels = array(
        'name'              => _x( 'Tallers Grup Categoría', 'tallers_grups' ),
        'singular_name'     => _x( 'Tallers Grup Categoría', 'tallers_grups' ),
        'search_items'      => __( 'Search Tallers Grup Categoría' ),
        'all_items'         => __( 'Todas Tallers Grup Categoría' ),
        'parent_item'       => __( 'Parent Tallers Grup Categoría' ),
        'parent_item_colon' => __( 'Parent Tallers Grup Categoría:' ),
        'edit_item'         => __( 'Editar Tallers Grup Categoría' ),
        'update_item'       => __( 'Actualizar Tallers Grup Categoría' ),
        'add_new_item'      => __( 'Agregar nuevo Tallers Grup Categoría' ),
        'new_item_name'     => __( 'Nuevo Tallers Grup Categoría' ),
        'menu_name'         => __( 'Tallers Grup Categoría' ),
    );

    $args = array(
        'hierarchical'      => true,
        'labels'            => $labels,
        'show_ui'           => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'rewrite'           => array( 'slug' => 'tallers_grups' ),
    );
register_taxonomy( 'tallers_grups', array( 'tallers_grup' ), $args );
}

function add_tallers_grup_caps() {
        $role = get_role( 'administrator' );

        $role->add_cap( 'edit_tallers_grup' ); 
        $role->add_cap( 'edit_tallers_grups' ); 
        $role->add_cap( 'edit_tallers_grups' ); 
        $role->add_cap( 'publish_tallers_grups' ); 
        $role->add_cap( 'read_tallers_grup' ); 
        $role->add_cap( 'read_private_tallers_grups' ); 
        $role->add_cap( 'delete_tallers_grup' ); 
        $role->add_cap( 'edit_published_tallers_grups' ); 
        $role->add_cap( 'delete_published_tallers_grups' );
        $role->add_cap( 'edit_create_tallers_grup' );
        $role->add_cap( 'edit_create_tallers_grups' );
}
add_action( 'admin_init', 'add_tallers_grup_caps');

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

WordPress自定义查询:使用多种帖子类型时,“ orderby” =>“日期”不起作用

单个自定义帖子类型模板(WordPress使用Timber / Twig)不起作用

WordPress自定义帖子类型存档页面wp_query分页不起作用

自定义帖子类型-类别添加按钮不起作用

WordPress自定义帖子类型

按存档文件中页面属性对自定义帖子类型进行排序不起作用

WP_Query具有分类法的自定义帖子类型不起作用

Wordpress 自定义帖子类型当前帖子

WordPress的自定义帖子类型帖子不显示

自定义功能在Wordpress中不起作用

自定义 wordpress 分类功能不适用于自定义帖子类型

WordPress:使用wp_insert_post()填充自定义帖子类型字段

将PubSubHubbub订户POST通知处理为自定义帖子类型WordPress

插件功能仅启用自定义帖子类型

自定义帖子类型注册功能隐藏页面

使Wordpress中的自定义帖子类型不可搜索

在Wordpress中显示自定义帖子类型的内容

WordPress自定义帖子类型列排序查询

自定义帖子类型Wordpress按类别查询

自定义帖子类型中的Wordpress列表类别

WordPress:自定义帖子类型导致404页

排序和显示自定义帖子类型Wordpress

在Wordpress中创建隐藏的自定义帖子类型

从Wordpress自定义帖子类型获取标题

Wordpress自定义帖子类型分类模板

从Wordpress取消注册自定义帖子类型

停止显示自定义帖子类型的wordpress搜索

简码内的Wordpress自定义帖子类型循环

WordPress的自定义帖子类型变量重叠?