Reputation: 1783
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:
Upvotes: 1
Views: 2913
Reputation: 11670
Edited the code:
add_filter('manage_edit-{custom_post_type}_columns', 'mytheme_categoy_id_column', 10, 2);
if (!function_exists('mytheme_categoy_id_column')) {
function mytheme_categoy_id_column($cat_columns){
$cat_columns['cat_id'] = esc_html__('Category ID', 'mytheme');
return $cat_columns;
}
}
add_filter ('manage_{custom_post_type}_custom_column', 'mytheme_custom_column_content', 10,3);
if (!function_exists('mytheme_custom_column_content')) {
function mytheme_custom_column_content($deprecated, $column_name, $term_id){
if ($column_name == 'cat_id') {
return $term_id;
}
}
}
Upvotes: 1
Reputation: 989
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);
Upvotes: 1