I need to change the rewrite-slug of the built in post-type ‘post’ to ‘example.com/magazine/news/any-nice-news-item’.

When I re-register the post-type ‘post’ and set the rewrite-slug to ‘magazine/news’ it works fine. But now I’m not sure about any side-effects. Does anybody have any positive or negative experience with that?

Here is the code:

register_post_type( 'post', array(
    'labels' => array(
        'name_admin_bar' => _x( 'Post', 'add new on admin bar' ),
    ),
    'public'  => true,
    /* internal use only. don't use this when registering your own post type. */
    '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
    'capability_type' => 'post',
    'map_meta_cap' => true,
    'hierarchical' => false,
    'rewrite' => array('slug' => 'magazine/news'),
    'query_var' => false,
    'delete_with_user' => true,
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
) );

3 Answers
3

You do not need to re register post type.

Symply go in you backend, Settings > Permalinks and set the permalink structure to a custom one: /magazine/news/%postname%/ then save changes.

See image below:


enter image description here

Leave a Reply

Your email address will not be published. Required fields are marked *