默认的 WordPress 带有一个默认的帖子类型,带有“post”的标签!
我想把这个蛞蝓换成另一个,而不会有任何头痛!
我的意思是,例如,改变子弹post
to article
.
我怎样才能做到这一点?
Update
这就是我要的 :
function _slug(){
$args = array(
'rewrite' => array(
'slug' => 'article',
),
);
register_post_type('post',$args);
}
add_action('init', '_slug');
但是,这行不通!
一种方法是使用 post 类型 argsfilter在functions.php文件上(确保它在注册帖子类型后运行):
$post_type = <POST TYPE NAME> # Define your own as a string
$new_slug = <WANTED SLUG> # Define your own as a string
add_filter( 'register_post_type_args', function($args, $post_type){
if ( 'post_type' == $post_type )
$args['rewrite'] = array( 'slug' => $new_slug );
return $args;
}, 10, 2 );
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)