呼叫register_taxonomy()
具有\'show_admin_column\' => TRUE
WordPress将自动创建您的列。此参数为added in version 3.5. 您不再需要自定义筛选器。
我编写了一个小插件来演示这种情况:t5-taxonomy-location.
这是注册码:
protected function register_taxonomy()
{
$this->set_labels();
$args = array (
\'labels\' => $this->labels,
\'label\' => $this->labels[\'singular_name\'],
\'public\' => TRUE,
\'show_in_nav_menus\' => TRUE,
\'show_ui\' => TRUE,
\'show_tagcloud\' => TRUE,
\'rewrite\' => array (
\'slug\' => _x( \'location\', \'slug\', \'plugin_t5_tax_location\' ),
\'with_front\' => apply_filters( \'t5_tax_location_slug_front\', FALSE )
),
\'query_var\' => \'location\',
\'hierarchical\' => TRUE,
// New in WordPress 3.5
// see http://core.trac.wordpress.org/ticket/21240
\'show_admin_column\' => TRUE
);
$tax_post_types = apply_filters(
\'t5_tax_location_post_types\',
array( \'post\', \'page\', \'attachment\' )
);
register_taxonomy( $this->taxonomy, $tax_post_types, $args );
}