6

I removed the categories column from "All posts" page by applying this code.

add_filter("manage_edit-post_columns", "my_post_edit_columns");
function my_post_edit_columns($columns){
  unset($columns['categories']);
  return $columns;
}

This code removed categories column. But still i see the categories filter in the top. Is there a way to remove it other than using CSS to hide it?

Thanks

1
  • 1
    That's because there is no relation between the categories column and the filter. You should look for another hook/filter with which you can remove the filter on top.
    – hakre
    Dec 31 '11 at 21:39
6

I tested this and it works for removing the categories dropdown on the All Posts page:

add_action( 'load-edit.php', 'no_category_dropdown' );
function no_category_dropdown() {
    add_filter( 'wp_dropdown_cats', '__return_false' );
}

-- below: old answer when I misunderstood the question --

The code you posted works just fine for me. But here's an alternative you might try:

add_filter("manage_posts_columns", "my_post_edit_columns" );
function my_post_edit_columns($columns){
    unset($columns['categories']);
    return $columns;
}

This will also impact other post types that have a 'categories' column.

9
  • It's not about the column, but the filter on top of the table (as written in the question).
    – hakre
    Dec 31 '11 at 21:40
  • Ah, I understand now. I was thinking of the screen options checkbox. Dec 31 '11 at 21:49
  • Yep. I want to remove that categories filter. I searched for hooks in this site but couldn't find anything. :( Dec 31 '11 at 21:56
  • Edited my answer and added new code now that I understand the question. Sorry for my confusion! :) Dec 31 '11 at 22:22
  • 1
    Remove bulk action with: add_filter( 'bulk_actions-' . 'edit-post', '__return_empty_array' ); Not sure about date, I'm looking though. Dec 31 '11 at 22:49
1

I think the select elements are passed through the wp_dropdown_cats filter. So you should be able to add a filter to that which returns a blank string.

3
  • Can you give me some sample code? I'll try it Dec 31 '11 at 22:13
  • add_filter( 'wp_dropdown_cats', 'remove_dropdown_cats' ); function remove_dropdown_cats(){ return ''; } edit: go with Kailey's code, attatching it all to the load-edit.php action is a good idea. Dec 31 '11 at 22:23
  • Is it possible to apply code for "date" and "bulk actions" filter too? Dec 31 '11 at 22:45
0

Here you go

add_filter('wp_dropdown_cats', '__return_false');

Here is the original wp_dropdown_cats function, this filter will return default post categories

2
  • Please edit your answer, and add an explanation: why could that solve the problem?
    – fuxia
    Nov 20 '20 at 5:29
  • If this is just a filter for the dropdown's HTML I'd expect you'd want return empty string not false?
    – Rup
    Nov 20 '20 at 9:24

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.