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.
Opens WPIDE on
Code
// 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 add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.