Deregistering Custom Post Types

Deregistering Custom Post Types from WordPress is easy and simple.

Follow the steps below:

<?php
/**
 * Deregister matching post types.
 */
function unregister_custom_post_types() {
    global $wp_post_types;
    foreach( array( 'services', 'staffs', 'projects', 'testimonials' ) as $post_type ) {
        if ( isset( $wp_post_types[ $post_type ] ) ) {
            unset( $wp_post_types[ $post_type ] );
        }
    }
}
add_action( 'init', 'unregister_custom_post_types', 20 );

Leave a Reply