Created
February 9, 2025 10:10
-
-
Save mommaroodles/96645b25ed418bf4518ae7f5af116d91 to your computer and use it in GitHub Desktop.
Unregister a custom post type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Unregister a custom post type in WordPress. | |
*/ | |
function remove_custom_post_type() { | |
// Check if the post type exists before attempting to unregister it | |
$post_type = 'your_custom_post_type'; // Replace with the slug of the custom post type you want to remove | |
if (post_type_exists($post_type)) { | |
unregister_post_type($post_type); | |
} | |
} | |
add_action('init', 'remove_custom_post_type', 20); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment