我想将默认的帖子类型URL重写为/blog/2016/11/my-post-name/
不影响其他帖子类型的url。我试过:
add_action(\'admin_menu\',\'remove_default_post_type\');
function remove_default_post_type() {
remove_menu_page(\'edit.php\');
}
add_action( \'init\', \'set_default_post_type\', 1 );
function set_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/%year%/%monthnum%/%postname%/\',
\'with_front\'=> false,
),
\'query_var\' => false,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'trackbacks\', \'custom-fields\', \'comments\', \'revisions\', \'post-formats\' ),
)
);
}
但没有成功。url保持为
/blog/my-post
. 有没有一种方法可以让permalinks成为默认的post类型,比如
/blog/2016/11/my-post-name/
(其中2016年为发布年份,11年为发布月份)不影响其他发布类型URL?