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.

Example

This will delete post type with name ‘blocks’.

unregister_post_type() – Source

Happy Coding..

Leave a Reply

3 Comments

  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?

    Thanks!

  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