-
-
Save johnkolbert/769160 to your computer and use it in GitHub Desktop.
<?php | |
/* | |
* Usage for a custom post type named 'movies': | |
* unregister_post_type( 'movies' ); | |
* | |
* Usage for the built in 'post' post type: | |
* unregister_post_type( 'post', 'edit.php' ); | |
*/ | |
function unregister_post_type( $post_type, $slug = '' ){ | |
global $wp_post_types; | |
if ( isset( $wp_post_types[ $post_type ] ) ) { | |
unset( $wp_post_types[ $post_type ] ); | |
$slug = ( !$slug ) ? 'edit.php?post_type=' . $post_type : $slug; | |
remove_menu_page( $slug ); | |
} | |
} | |
?> |
Priority of '11' worked for me (WordPress default is '10').
Where exactly do you place this code? in functions.php? and then when the custom post types are deregistered does it have to stay in there?
WordPress has this built in since 4.5: https://developer.wordpress.org/reference/functions/unregister_post_type/
@fgilio good find, just note that the function can't be used to remove default post types.
None of that worked for me; but probably because the CPT's were from the theme it self. "Flora"
What did work: [placed within child theme --> functions.php]
function delete_post_type(){
unregister_post_type( 'wyde_portfolio' );
unregister_post_type('wyde_team_member');
unregister_post_type('wyde_testimonial');
}
add_action('init','delete_post_type');
Then used a plugin to rid DB of the post's data.
CPT Cleanup
None of this worked for me.. Why do we continue to use this horrible CMS? #clownworld
@fgilio it may be built in. - but doesn't work as this thread shows it is a clusterF8ck nightmare of a solution.
If you created the cpti in the admin panel - you have to delete it from the admin panel . functions.php doesn't seem to have any effect at all - shocking , I know. .. smh
It did not work for me until gave it the priority '100':