我使用以下代码添加自定义分类列:
function manage_my_category_columns($columns)
{
if ( !isset($_GET[\'taxonomy\']) || $_GET[\'taxonomy\'] != \'products\' )
return $columns;
$columns[\'image_column\'] = \'Image\';
return $columns;
}
add_filter(\'manage_edit-products_columns\',\'manage_my_category_columns\');
function manage_category_custom_fields($deprecated,$column_name,$term_id){
if ($column_name == \'image_column\') {
$t_id = $term_id;
$cat_meta = get_option( "products_$t_id");
echo "<img src=\'".$cat_meta[\'img\']."\' style=\'height:50px;width:50px;\'/>";
}
}
add_action(\'manage_products_custom_column\',\'manage_category_custom_fields\',10,3);
添加新类别时,创建后不会立即显示自定义列:
页面刷新后,将显示自定义列:
有没有办法在创建新类别后立即用默认列显示自定义列?