how to rewrite args in a custom post type from your functions.php?

The $rewrite parameter of register_post_type() accepts either a boolean or an array. We can overwrite the existing value of $rewrite with the array of our desired settings:

function overwrite_gallery_slug( $args, $post_type ) {
    if ( $post_type === 'gallery') {

            $args['rewrite'] = array (
                'slug'       => 'team-murray',
                'with_front' => false,
            );
    }

    return $args;
}
add_filter( 'register_post_type_args', 'overwrite_gallery_slug', 10, 2 );

Remember to flush permalinks after implementing this code.

error code: 523