# Remove a Post Type or Taxonomy Added by a Theme or Plugin

> Unregisters post types or taxonomies you never use, such as a theme's "Portfolio" or "Projects", to tidy the admin menu and URLs.

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

## Code

```php
// Post types and taxonomies to remove.
$wpide_remove_types      = array( 'portfolio' );
$wpide_remove_taxonomies = array( 'portfolio_category' );

add_action( 'init', function () use ( $wpide_remove_types, $wpide_remove_taxonomies ) {
    foreach ( $wpide_remove_taxonomies as $taxonomy ) {
        if ( taxonomy_exists( $taxonomy ) && ! get_taxonomy( $taxonomy )->_builtin ) {
            unregister_taxonomy( $taxonomy );
        }
    }

    foreach ( $wpide_remove_types as $type ) {
        if ( post_type_exists( $type ) && ! get_post_type_object( $type )->_builtin ) {
            unregister_post_type( $type );
        }
    }
}, 999 );
```

## Notes

Existing items stay in the database and come back if you deactivate this snippet. Built-in types cannot be removed.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Remove a Post Type or Taxonomy Added by a Theme or Plugin" 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/
