Site icon Hip-Hop Website Design and Development

Changing slug of all posts

I have a site with around a dozen custom post types. I’d like to change the default post type so that it’s URL has a slug of /news/.

In my functions file I have:

    add_action( 'init', 'change_post_object' );
    // Change dashboard Posts to News
    function change_post_object() {
        $get_post_type = get_post_type_object('post');
        $labels = $get_post_type->labels;
        $labels->name = 'News';
        $labels->singular_name = 'News';
        $labels->add_new = 'Add News Item';
        $labels->add_new_item = 'Add News Item';
        $labels->edit_item = 'Edit News';
        $labels->new_item = 'News';
        $labels->view_item = 'View News Item';
        $labels->search_items = 'Search News';
        $labels->not_found = 'No News found';
        $labels->not_found_in_trash = 'No News found in Trash';
        $labels->all_items = 'All News';
        $labels->menu_name = 'News';
        $labels->name_admin_bar = 'News';
        $rewrite = $get_post_type->rewrite;
        $rewrite->slug = 'news-events/news';
        $rewrite->with_front = 'true';
    }

… Which all works apart from the rewrite of the slug.

Lots of posts suggest just changing the permalink structure on the Permalinks page from /%postname%/ to /news/%postname%/. This works – but breaks all the other custom post types.

How can I do this please?!