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

2 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!

Next ArticleWebsites To Find Free stock images