我必须重新注册WordPress默认帖子类型才能将帖子更改为“博客”,更改固定链接结构对我来说不起作用,因为它也重写自定义帖子类型slug。所以我在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 );
工作得很好,满足了我的需要。但问题是现在它在管理栏中显示两次“发布”项目。为什么会这样?
答案 0 :(得分:2)
只需添加'show_ui'=>假
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' ),
));