Created
April 17, 2018 15:54
-
-
Save hwkdev/98ebdea582e72e315283d9c22532843c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <?php | |
| add_action('init', 'hwk_deregister_builtin_post_type'); | |
| function hwk_deregister_builtin_post_type(){ | |
| global $wp_post_types; | |
| $unregister = array( | |
| 'post', | |
| 'page', | |
| ); | |
| foreach($unregister as $post_type){ | |
| if(!post_type_exists($post_type)) | |
| continue; | |
| $post_type_object = get_post_type_object($post_type); | |
| $post_type_object->remove_supports(); | |
| $post_type_object->remove_rewrite_rules(); | |
| $post_type_object->unregister_meta_boxes(); | |
| $post_type_object->remove_hooks(); | |
| $post_type_object->unregister_taxonomies(); | |
| unset($wp_post_types[$post_type]); | |
| do_action('unregistered_post_type', $post_type); | |
| $wp_post_types[$post_type] = new stdClass(); | |
| $wp_post_types[$post_type]->show_in_menu = false; | |
| $wp_post_types[$post_type]->publicly_queryable = false; | |
| $wp_post_types[$post_type]->_builtin = false; | |
| $wp_post_types[$post_type]->name = false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment