Deregistering Custom Post Types

If you want to deregister custom post types in a Themify theme, follow these steps:

1. create a custom-functions.php in the theme folder if it does not exist.

2. paste this code in it

<?php
/**
 * Deregister matching post types.
 */
function custom_unregister_theme_post_types() {
    global $wp_post_types;
    foreach( array( 'portfolio', 'gallery', 'team', 'testimonial', 'highlight' ) as $post_type ) {
        if ( isset( $wp_post_types[ $post_type ] ) ) {
            unset( $wp_post_types[ $post_type ] );
        }
    }
}
add_action( 'init', 'custom_unregister_theme_post_types', 20 );

/**
 * Remove matching post types from list of post types supported by Themify.
 *
 * @param $types
 * @return array
 */
function custom_supported_post_types( $types ) {
    $removed_types = array( 'portfolio', 'gallery', 'team', 'testimonial', 'highlight' );
    return array_diff( $types, $removed_types );
}
add_action( 'themify_post_types', 'custom_supported_post_types', 77 );

/**
 * Remove matching post types from Builder module list.
 *
 * @param $types
 * @return array
 */
function custom_builder_modules( $types ) {
    $removed_types = array( 'portfolio', 'gallery', 'team', 'testimonial', 'highlight' );
    return array_diff( $types, $removed_types );
}
add_filter( 'themify_builder_modules_list', 'custom_builder_modules' );
?>

3. save the file.

In themes like Event or Music that have a custom Events widget, the widget can be removed using this additional code:

<?php
/**
 * Deregister Events widget.
 */
function custom_remove_events_widget() {
    unregister_widget( 'Themify_Events' );
}
add_action( 'widgets_init', 'custom_remove_events_widget', 11 );
?>

Own the Online World with the New Ultra Games Skin + Get 50% OFF Ultra with code GAMES!