wordpress 后台添加自定义分类筛选?

参考网址:http://wordpress.stackexchange.com/questions/578/adding-a-taxonomy-filter-to-admin-list-for-a-custom-post-type

/* overwrite drop down select by category
-----------------------------------------*/
add_action('restrict_manage_posts','overwrite_listings_by_category');
function overwrite_listings_by_category() {
    global $typenow;
    global $wp_query;

    if ($typenow=='post') {
        $taxonomy = 'category';
        $category_taxonomy = get_taxonomy($taxonomy);
		//return print_r($wp_query->query);
        return wp_dropdown_categories(array(
            'show_option_all' =>  __("Show All {$category_taxonomy->label}"),
            'taxonomy'        =>  $taxonomy,
            'name'            =>  'cat',
            'orderby'         =>  'name',
            'selected'        =>  @$wp_query->query['cat'],
            'hierarchical'    =>  true,
            'depth'           =>  5,
            'show_count'      =>  true, // Show # listings in parens
            'hide_empty'      =>  true, // Don't show businesses w/o listings
        ));
    }
}

The Screenshots:

...let's check out some screen shots for the finished product:

Listings list page with No Filtering:

wordpress 后台添加自定义分类筛选?_第1张图片

Listings list page With Filtering:

wordpress 后台添加自定义分类筛选?_第2张图片



你可能感兴趣的:(wordpress 后台添加自定义分类筛选?)