默认贴标签显示两次在管理栏



我必须重新注册WordPress默认的帖子类型来更改帖子段为"blog",更改永久链接结构对我不起作用,因为它也重写了自定义的帖子类型段。所以我在function。php

中使用了下面的代码
function my_new_default_post_type() {
register_post_type( 'post', array(
    'labels' => array(
        'name_admin_bar' => _x( 'Post', 'add new on admin bar' ),
    ),
    'public'  => true,
    '_builtin' => false,
    '_edit_link' => 'post.php?post=%d',
    'capability_type' => 'post',
    'map_meta_cap' => true,
    'hierarchical' => false,
    'rewrite' => array( 'slug' => 'blog' ),
    'query_var' => false,
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
) );
flush_rewrite_rules();
}
add_action( 'init', 'my_new_default_post_type', 1 );

它工作得很好,满足了我的需要。但问题是,现在它显示"post"项目两次在管理栏。为什么会这样呢

只需添加'show_ui' => false

register_post_type( 'post', array(
'labels' => array(
    'name_admin_bar' => _x( 'Post', 'add new on admin bar' ),
),
'public'  => true,
'_builtin' => false,
'_edit_link' => 'post.php?post=%d',
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => false,
'show_ui' => false,
'rewrite' => array( 'slug' => 'blog' ),
'query_var' => false,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),

));

最新更新