我在一个插件中为我的 wordpress 主题创建了一个自定义分类法分类法。激活插件后,我导航到自定义帖子类型的管理部分,该站点显示的所有帖子和页面。此外,当我尝试从自定义帖子类型管理区域中删除这些帖子和页面时,我收到“无效帖子类型”错误。有没有人遇到过这种情况,有解决办法吗?
'code'add_action ('init', 'create_post_type' );
function create_post_type() {
register_post_type( 'my_slide',
array(
'labels' => array(
'name' => __( 'Slides' ),
'singular_name' => __( 'Slide' ),
'add_new' => 'Add New',
'add_new_item' => 'Add New Slide',
'edit' => 'Edit',
'edit_item' => 'Edit Slide',
'new_item' => 'New Slide',
'view' => 'View',
'view_item' => 'View Slide',
'search_items' => 'Search Slides',
'not_found' => 'No Slides found',
'not_found_in_trash' => 'No Slides found in Trash',
'parent' => 'Parent Slide'
),
'public' => true,
'has_archive' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'map_meta_cap' => true,
'query_var' => false,
'register_meta_box_cb' => 'slide_meta_box_add',
'supports' => array('title', 'editor', 'thumbnail', 'post-formats', 'Custom Featured Image links')
)
);
}
add_action( 'init', 'create_slider_taxonomies', 0 );
function create_slider_taxonomies() {
register_taxonomy(
'slider_category',
array( 'my_slide' ),
array(
'labels' => array(
'name' => 'Slide Category',
'add_new_item' => 'Add New Slide Category',
'new_item_name' => 'New Slide Category Name'
),
'show_ui' => true,
'show_tagcloud' => false,
'show_admin_column' => true,
'hierarchical' => true
)
);
}'code'