WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Anyone know of a way to deregister custom post types ?

Is there an equivalent to register_post_type() ?

share|improve this question
ANY ONE ELSE SEARCHING THIS . When you register a custom post type nothing is being saved to the database . The posts table in the wp db is unstructured . Its only registering with the internals of the wp script that you can create an entry into the posts table with the type of what ever you created with register posts . Hope that helps some one else . – Prospero Feb 3 at 23:00
up vote 28 down vote accepted

Currently there is not a function for unregistering a post type, the process however is quite simple.

Andrew Nacin provided some code over on trac, found here and posted below.

if ( ! function_exists( 'unregister_post_type' ) ) :
function unregister_post_type( $post_type ) {
    global $wp_post_types;
    if ( isset( $wp_post_types[ $post_type ] ) ) {
        unset( $wp_post_types[ $post_type ] );
        return true;
    return false;

Unregistering a built-in post type will have unknown effects on WordPress, so please do so at your own risk. Unregistering a custom post type should be perfectly safe, but would naturally do no cleanup on your installation(ie. unregistering a post type does not equate to data removal from the database).

I can imagine a few scenarios where this could be required, but the more sensible approach(where possible), would be to simply not register the post type in the first place if it's not wanted.

share|improve this answer
Sure - this is mainly to get rid of a custom post type I added and then decided didn't really fit. That code worked well. Thanks. – anu Nov 9 '10 at 14:05
You're welcome.. :) If you're adding your own post types in code form, the easier solution would be to simply remove the function/code you run that adds them. Also note, removing post types does not flush them out from your posts table, so you may have redundanct entries in that table. – t31os Nov 9 '10 at 14:16
@anu: The only thing that stays "permanent" if you don't execute the register_post_type() on each page load (init) is probably the permalink structure (refresh it and it will be gone), and the posts in the database, which you can remove by doing DELETE FROM wp_posts WHERE post_type = '[your custom post type]'. – Jan Fabry Nov 9 '10 at 14:35
Interestingly, I did remove the register_post_type code for that custom_post_type, and I hadn't added any posts to that cpt, but it didn't remove the admin UI. – anu Nov 9 '10 at 14:36
Or course, now that I try this again, it works as you guys described - ie the admin UI for the new cpt has gone. Probably me being a muppet :) Useful info anyway, so thanks. – anu Nov 9 '10 at 14:37

As t31os noted it is easy to remove post type from global variable.

But if you mean non-core post type then it would be better to lookup code that registers it and unhook with remove_action() (if it is decent code it should be hooked rather than run directly).

share|improve this answer
register_post_type() is not a function that lends itself nicely to hooking. The normal way to register a post type is to run the function directly in a function hooked on init. Removing that action may have undesired effects, as there will often be other functionality removed with that function. – John P Bloch Nov 9 '10 at 13:59
@John P Bloch yep, I am aware of that. Sometimes you end up rebuilding all of init to get it right, in the end it depends on specific code and its quality/sanity – Rarst Nov 9 '10 at 14:21

This worked for me, like Rarst said using the remove_action() if possible.

add_action( 'after_setup_theme','remove_foundation_options', 100 );

function remove_foundation_options() {   
    remove_action( 'init', 'Orbit');    
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.