Unregister a Post type using unregister_post_type()

Unregister a post type using unregister_post_type

Unregistering a post type is a serious issue for child theme developers. Because parent theme contains some unwanted post types and that lead to some confusions for clients. WordPress 4.5 solves this problem. It includes a function for unregister a post type – unregister_post_type().

unregister_post_type() unregister unwanted post types. But it doesn’t unregister built in post types post , page attachment, revision etc.


This will delete post type with name ‘blocks’.

unregister_post_type() – Source

Happy Coding..

Leave a Reply


  1. These is nice information, I really appreciate content, which is cover over here, Fantastic.

    Thank You

  2. Jonny

    I have a couple of questions:

    – Where do you put this code? In functions.php, or in post.php? I’ve been reading about unregister_post_type() on a number of sites, but it’s not clear anywhere what to actually do with the code.
    – When can you delete the code? How do you know when it has actually unregistered the post type?


    • You can include the short snippet as is in functions.php (of your child theme, that you’re obviously using, right? 🙂 ) – that would run the function as WordPress intended.

      Otherwise you could copy the function above and rename it (and rename it in the snippet too) and copy both to functions.php. — If you just copy it as is you’ll get a “can’t redefine function” error, as you probably already know if you (like me) found the post.php file through the error message…

  3. Hi Dhinju,

    Can you explain me how to use this code, we are running Integrity Pro Theme and installed CPT UI to create a CPT named “Community” after few days we uninstalled the CPT UI and the new CPT remained. Later on we were asked to remove the CPT. Now i tried all possible ways and no result. How do i use the code above? Please explain.

Next ArticleWebsites To Find Free stock images