更新时间:2022-10-16 16:53:24
试试这个
//显示列标题
函数custom_column_header($ columns){
$ columns ['header_name'] ='用于显示的标题名称';
个返回$列;
}
add_filter( manage_edit-(your-texanomy)_columns,'custom_column_header',10);
//要显示列值
函数custom_column_content($ value,$ column_name,$ tax_id){
返回$ tax_id;
}
add_action( manage_(your-texanomy)_custom_column,‘custom_column_content’,10,3);
I'm trying to add the category ID to the category list table for a custom post type using manage_{$taxonomy}_custom_column
, and I found out that the function is now deprecated.
The filter is now red on the following page with no usage information available: https://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column
And the following page says the filter is now deprecated, with no followup information since version 3: http://adambrown.info/p/wp_hooks/hook/manage_{$taxonomy}_custom_column
I came across this solution on github, but it doesn't work: https://gist.github.com/maxfenton/593473788c2259209694
I've not found any solution that serves as a replacement for manage_{$taxonomy}_custom_column
. Does anyone have any idea how to go about adding a category ID column in the category grid view?
Here is a screenshot showing where I want to add the ID:
Try this
// To show the column header
function custom_column_header( $columns ){
$columns['header_name'] = 'Header Name for Display';
return $columns;
}
add_filter( "manage_edit-(your-texanomy)_columns", 'custom_column_header', 10);
// To show the column value
function custom_column_content( $value, $column_name, $tax_id ){
return $tax_id ;
}
add_action( "manage_(your-texanomy)_custom_column", 'custom_column_content', 10, 3);