• Skip to primary navigation
  • Skip to main content
OsomCode

OsomCode

Awesome code tutorials for WordPress and Genesis

  • Subscribe
  • My account
    • Edit profile
    • Favorites
    • Update credit card
  • Login

Unregister a Custom Post Type in WordPress

Discover in this tutorial how to unregister a Custom Post Type (CPT) in WordPress using code.

The other day a subscriber told me that he is using Genesis Blocks Pro, but he prefers not to use the Custom Post Type that comes with it. Not only that, but he doesn’t want it to be visible to clients either.

Menu item created by CPT

To remove the associated menu you could use the strategy we’ve used in other tutorials, but in this case it would be best to unregister the Custom Post Type directly.

Result after unregistering the CPT.

Let’s see how you can do this.

Snippet to unregister a Custom Post Type in WordPress

Add the following code at the end of functions.php or in your functionality plugin:

To see this and another 839 code snippets of this website, login or subscribe here.

To unregister “Portfolio Items” you have to use the name that the CTP was registered with, in this case, gpb_portfolio.

Obviously, you can change the slug to the one of the Custom Post Type you are interested in.

To find out what the name the CPT you can click on the CPT menu and inspect the URL that loads. You will see something like this:

https://yourwebsite/wp-admin/edit.php?post_type=gpb_portfolio

Indeed, the key is in the final part post_type=gpb_portfolio.

Conclusion

Now you know how to unregister a Custom Post Type created by a third party plugin in WordPress.

Any questions? Let me know in the comments.

And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉

CPT PHP WordPress

To leave read and make questions about this code, you can login or register.

  • About OsomCode
  • FAQ
  • Contact

Legal Notice · Privacy Policy · Cookie Policy · Terms and conditions
Copyright © 2023

Lost your password?