Remove date and category filters when editing custom post types

To remove the dates:

function my_remove_date_filter( $months ) {
    global $typenow; // use this to restrict it to a particular post type
    if ( $typenow == 'post' ) {
        return array(); // return an empty array
    }
    return $months; // otherwise return the original for other post types
}
add_filter('months_dropdown_results', 'my_remove_date_filter');

To remove categories:

function my_remove_cat_filter( $output ) {
    global $typenow;
    if ( is_admin() && $typenow == 'post' ) {
        return ''; // return a blank string
    }
    return $output;
}
add_filter('wp_dropdown_cats', 'my_remove_cat_filter');

Leave a Comment