As default wordpress came with a default post type with the slug of "post"!
I wanna change this slug to another one without any headache!
I mean, for example, change the slug post
to article
.
How can i achieve that ?
Update
This is what i want :
function _slug(){
$args = array(
'rewrite' => array(
'slug' => 'article',
),
);
register_post_type('post',$args);
}
add_action('init', '_slug');
But, well that doesn't work!
One of the ways is to use a post type args filter on functions.php file (make sure it run after post type registered):
$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 );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With