Skip to content

Instantly share code, notes, and snippets.

@johnkolbert
Created January 7, 2011 05:45
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save johnkolbert/769160 to your computer and use it in GitHub Desktop.
Save johnkolbert/769160 to your computer and use it in GitHub Desktop.
Unregisters a post type and removes the menu item
<?php
/*
* Usage for a custom post type named 'movies':
* unregister_post_type( 'movies' );
*
* Usage for the built in 'post' post type:
* unregister_post_type( 'post', 'edit.php' );
*/
function unregister_post_type( $post_type, $slug = '' ){
global $wp_post_types;
if ( isset( $wp_post_types[ $post_type ] ) ) {
unset( $wp_post_types[ $post_type ] );
$slug = ( !$slug ) ? 'edit.php?post_type=' . $post_type : $slug;
remove_menu_page( $slug );
}
}
?>
@heatherannelynn
Copy link

If you created the cpti in the admin panel - you have to delete it from the admin panel . functions.php doesn't seem to have any effect at all - shocking , I know. .. smh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment