3

The answers to this question give excellent instructions for adding filters to the admin edit.php screen for custom post types. But they don't explain how to remove the existing filters on date and category. Does anyone know whether this is possible, and if so how to do it?

1

I looked at this recently and couldn't really find a way other than hiding them via css.

  • Thanks, I feared as much. And even that's not easy as I only want to do it on the page for one particular custom post type. – lpryor Aug 31 '11 at 14:17
  • 1
    It's actually not that hard: gist.github.com/1184759 – mfields Aug 31 '11 at 21:27
  • OK that's great, thanks. That's not a technique I'd come across before. I'll work my way through it! – lpryor Sep 6 '11 at 10:01
0

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
}

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');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.