我必须重新注册WordPress的默认帖子类型才能将帖子slug更改为“blog”,更改permalink结构对我来说不起作用,因为它还会重写自定义帖子类型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 );
它工作得很好,满足了我的需要。但现在的问题是,它在管理栏中两次显示“post”项。为什么会这样?