You need to hook in to the Posts list table using the manage_posts_extra_tablenav
filter, but you can show the filter yourself by using the wp_dropdown_categories()
function.
The only two $args
that you are really interested in are depth
and taxonomy
, but I’ve included all of the defaults below.
Full details of the wp_dropdown_categories()
function can be found in the Codex
add_filter('manage_posts_extra_tablenav', 'my_add_category_dropdown');
function my_add_category_dropdown(){
$args = array(
'show_option_all' => '',
'show_option_none' => '',
'option_none_value' => '-1',
'orderby' => 'ID',
'order' => 'ASC',
'show_count' => 0,
'hide_empty' => 1,
'child_of' => 0,
'exclude' => '',
'echo' => 1,
'selected' => 0,
'hierarchical' => 0,
'name' => 'cat',
'id' => '',
'class' => 'postform',
'depth' => 0,
'tab_index' => 0,
'taxonomy' => 'category',
'hide_if_empty' => false,
'value_field' => 'term_id',
);
wp_dropdown_categories($args);
}