如何在自定义帖子类型的类别网格中添加自定义列? [英] How to add custom column in category grid of custom post type?
问题描述
我试图使用 manage _ {$ taxonomy} _custom_column
将类别ID添加到自定义帖子类型的类别列表中,我发现该功能现已弃用。
以下页面上的过滤器现在为红色,没有可用的使用信息:
试试这个
//显示列标题
函数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);
这篇关于如何在自定义帖子类型的类别网格中添加自定义列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!