# Change the URL Slug of Any Taxonomy

> Changes the URL base of a category-style taxonomy registered by a theme or plugin, for example from /portfolio-category/ to /work-type/.

- Type: PHP
- Runs: Run everywhere
- Category: [Custom Post Types & Fields](https://wpide.com/library/category/post-types/)
- Tags: permalinks, slugs, taxonomies
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/change-taxonomy-slug/

## Code

```php
// Taxonomy => new slug.
$wpide_new_tax_slugs = array(
    'portfolio_category' => 'work-type',
);

add_filter( 'register_taxonomy_args', function ( $args, $taxonomy ) use ( $wpide_new_tax_slugs ) {
    if ( isset( $wpide_new_tax_slugs[ $taxonomy ] ) ) {
        $args['rewrite'] = array_merge( is_array( $args['rewrite'] ?? null ) ? $args['rewrite'] : array(), array( 'slug' => $wpide_new_tax_slugs[ $taxonomy ] ) );
    }

    return $args;
}, 10, 2 );
```

## Notes

Visit Settings > Permalinks once afterwards. For the built-in category and tag bases, use Settings > Permalinks instead.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Change the URL Slug of Any Taxonomy" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
