//what version of wordpress you are using
//since wp 3.5 you can pass parameter show_admin_column=>true
// hook into the init action and call create_book_taxonomies when it fires
add_action('init', 'create_book_taxonomies', 0);
// create two taxonomies, genres and writers for the post type "book"
function create_book_taxonomies() {
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
'name' => _x('Genres', 'taxonomy general name'),
'singular_name' => _x('Genre', 'taxonomy singular name'),
'search_items' => __('Search Genres'),
'all_items' => __('All Genres'),
'parent_item' => __('Parent Genre'),
'parent_item_colon' => __('Parent Genre:'),
'edit_item' => __('Edit Genre'),
'update_item' => __('Update Genre'),
'add_new_item' => __('Add New Genre'),
'new_item_name' => __('New Genre Name'),
'menu_name' => __('Genre'),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array('slug' => 'genre'),
);
register_taxonomy('genre', array('book'), $args);
}
Nguồn
2014-01-15 09:20:47
Chỉ cần lưu ý rằng bộ lọc 'manage_post-type_custom_column' chỉ hoạt động cho Loại bài đăng tùy chỉnh nơi' hierarchical => true' (như Pages). Đối với CPT, trong đó 'hierarchical => false' (như Posts), bạn nên sử dụng bộ lọc rất giống' manage_post-type_posts_custom_column'. Vì vậy, trong ví dụ cụ thể này, bạn nên thay đổi dòng 4 thành: 'add_action ('manage_banner_posts_custom_column', 'location_tax_column_info', 10, 2);' Thông tin thêm [tại đây] (http: // codex. wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column) – Tim