# Default Term for a Custom Taxonomy

> Gives a custom taxonomy a default term, like "Uncategorized" for categories, so items saved without a term still get one.

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

## Code

```php
// Taxonomy => default term name and slug.
$wpide_default_terms = array(
    'genre' => array( 'name' => 'General', 'slug' => 'general' ),
);

add_filter( 'register_taxonomy_args', function ( $args, $taxonomy ) use ( $wpide_default_terms ) {
    if ( isset( $wpide_default_terms[ $taxonomy ] ) && empty( $args['default_term'] ) ) {
        $args['default_term'] = $wpide_default_terms[ $taxonomy ];
    }

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

## Notes

WordPress creates the term on the next page load if it does not exist. Works for taxonomies registered on init by any plugin or theme.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Default Term for a Custom 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/
