admin管理员组文章数量:1410737
I have a categories and I have to display all categories id along with categories name.
Something like
Accessories(id=1)
featured(id=1)
OR
id Name
1 Accessories
2 featured
Is it possible to display without a plugin?
I have a categories and I have to display all categories id along with categories name.
Something like
Accessories(id=1)
featured(id=1)
OR
id Name
1 Accessories
2 featured
Is it possible to display without a plugin?
Share Improve this question edited Dec 19, 2019 at 20:29 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Dec 16, 2019 at 11:51 Naren VermaNaren Verma 2491 gold badge6 silver badges19 bronze badges1 Answer
Reset to default 1You can add new column using below code. replace (your-texanomy)
with your taxonomy slug. I have tested and its working fine. https://prnt.sc/qbibg0
#add header before category name
function taxonomy_custom_column_header( $columns ){
$columns = array_slice($columns, 0, 1, true) +
array("cat_id" => "ID") +
array_slice($columns, 1, count($columns) - 1, true) ;
return $columns;
}
add_filter( "manage_edit-(your-texanomy)_columns", 'taxonomy_custom_column_header', 10);
# add value to newly added column
function taxonomy_custom_column_content( $value, $column_name, $tax_id ){
if ( 'cat_id' == $column_name ) {
$content = $tax_id;
}
return $content;
}
add_action( "manage_(your-texanomy)_custom_column", 'taxonomy_custom_column_content', 10, 3);
本文标签: plugin developmentHow to display the category id along with category name on categories list
版权声明:本文标题:plugin development - How to display the category id along with category name on categories list? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744889368a2630678.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论