Anyone know of a way to deregister custom post types?

Is there an equivalent to register_post_type()?

  • 2
    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 . Commented Feb 3, 2016 at 23:00
  • 2
    As of WordPress 4.5 there is function to do that unregister_post_type. See Unregister a post type using unregister_post_type Commented Jul 12, 2016 at 4:54

5 Answers 5


As of WordPress 4.5 there is function to do that, unregister_post_type. Example:-

function delete_post_type(){
    unregister_post_type( 'blocks' );
  • this need to be on higher priority then the one used to register the post type otherwise it will not work Commented Jul 12, 2016 at 5:46
  • @Dhinju Divakaran it is not deleting the old post type from db which I am not using now. Commented Feb 3, 2017 at 5:48
  • its working, make sure you give high priority to this action compare to the action used to register the post type. Commented May 14, 2017 at 21:23
  • 2
    It's worth mentioning that unregister_post_type() does not delete anything from the database. It only prevents the post type from being registered. Commented Mar 3, 2018 at 0:40
  • This worked great for me, but keep in mind that you'll need to inform WordPress of the change by re-saving your Permalink structure in the Settings -> Permalinks admin page. Otherwise, pages with conflicting permalinks don't work correctly. Commented Feb 1, 2019 at 17:23

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.

  • 2
    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
    Commented Nov 9, 2010 at 14:16
  • 2
    @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
    Commented Nov 9, 2010 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
    Commented Nov 9, 2010 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
    Commented Nov 9, 2010 at 14:37
  • 3
    Update in Feb 2016 - this function was merged in core for WP 4.5.0 (to be lauched in April). Commented Feb 4, 2016 at 19:43

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');    

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).

  • 2
    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. Commented Nov 9, 2010 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
    Commented Nov 9, 2010 at 14:21

In WordPress version 4.5 and above they provide a function to remove post type (unregister_post_type). Example

function delete_post_type(){
unregister_post_type( 'jobs' );

It will work definately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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