Redeclare slug & name of custom post type?

WordPress provides the register_post_type_args filter to let users do this:

function wpd_modify_post_type( $args, $post_type ){
    if( 'reviews' == $post_type ){
        $args['labels']['name'] = 'New name';
        $args['labels']['singular_name'] = 'New singular name';
        $args['rewrite']['slug'] = 'new-slug';
    }
    return $args;
}
add_filter( 'register_post_type_args', 'wpd_modify_post_type', 10, 2 );

Keep in mind that if the slug changes, the user will need to flush rewrite rules manually for the new slug to start working, which can be done by visiting the Settings > Permalinks page in admin.

tech