我的媒体库的管理员中已经有以下代码:
function atelier_add_iCat_taxonomy() {
$labels = array(
\'name\' => \'iCats\',
\'singular_name\' => \'iCat\',
\'search_items\' => \'Search iCats\',
\'all_items\' => \'All iCats\',
\'parent_item\' => \'Parent iCat\',
\'parent_item_colon\' => \'Parent iCat:\',
\'edit_item\' => \'Edit iCat\',
\'update_item\' => \'Update iCat\',
\'add_new_item\' => \'Add New iCat\',
\'new_item_name\' => \'New iCat Name\',
\'menu_name\' => \'iCat\',
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => true,
\'query_var\' => \'true\',
\'rewrite\' => \'true\',
\'show_admin_column\' => \'true\',
);
register_taxonomy( \'iCat\', \'attachment\', $args );
}
add_action( \'init\', \'atelier_add_iCat_taxonomy\' );
我想一个过滤器,以确保属于某一类别的图像只显示。
尝试了以下方法,但它显示了主要类别,而不是我的自定义分类法。
function atelier_add_image_category_filter() {
$screen = get_current_screen();
if ( \'upload\' == $screen->id ) {
$dropdown_options = array( \'show_option_all\' => __( \'View all categories\', \'iCats\' ), \'hide_empty\' => false, \'hierarchical\' => true, \'orderby\' => \'name\', );
wp_dropdown_categories( $dropdown_options );
}
}
add_action( \'restrict_manage_posts\', \'atelier_add_image_category_filter\' );
我是否遗漏了什么,或者是否有其他解决方案?