Function automatically creates and applies filters from all taxonomies that apply to all custom post types which use them
This in short adds filter selects to the post screens in the WordPress admin.
function todo_restrict_manage_posts() { global $typenow; $args=array( 'public' => true, '_builtin' => false ); $post_types = get_post_types($args); if ( in_array($typenow, $post_types) ) { $filters = get_object_taxonomies($typenow); foreach ($filters as $tax_slug) { $tax_obj = get_taxonomy($tax_slug); wp_dropdown_categories(array( 'show_option_all' => __('Show All '.$tax_obj->label ), 'taxonomy' => $tax_slug, 'name' => $tax_obj->name, 'orderby' => 'term_order', 'selected' => $_GET[$tax_obj->query_var], 'hierarchical' => $tax_obj->hierarchical, 'show_count' => false, 'hide_empty' => true )); } } } function todo_convert_restrict($query) { global $pagenow; global $typenow; if ($pagenow=='edit.php') { $filters = get_object_taxonomies($typenow); foreach ($filters as $tax_slug) { $var = &$query->query_vars[$tax_slug]; if ( isset($var) ) { $term = get_term_by('id',$var,$tax_slug); $var = $term->slug; } } } return $query; } add_action( 'restrict_manage_posts', 'todo_restrict_manage_posts' ); add_filter('parse_query','todo_convert_restrict');


What Did You Think?