很多小伙伴小编,说 WordPress 后台怎么让文章、分类、显示 ID 信息,今天就简单分享一下,请接着往下看。
在当前使用的 WordPress 模板,找到函数文件:functions.php,然后插入以下代码:
// ID开始
/**
* WordPress后台文章、分类、标签、页面显示ID
*/
// 添加新列
function ssid_column($cols) {
$cols['ssid'] = 'ID';
return $cols;
}
// 列css
function ssid_css() {
?>
<style type="text/css">
#ssid { width: 50px; } /* Simply Show IDs */
</style>
<?php
}
// 显示ID
function ssid_value($column_name, $id) {
if ($column_name == 'ssid')
echo $id;
}
function ssid_return_value($value, $column_name, $id) {
if ($column_name == 'ssid')
$value = $id;
return $value;
}
// 通过动作/过滤器输出各种表格和CSS
function ssid_add() {
add_action('admin_head', 'ssid_css');
add_filter('manage_posts_columns', 'ssid_column');
add_action('manage_posts_custom_column', 'ssid_value', 10, 2);
add_filter('manage_pages_columns', 'ssid_column');
add_action('manage_pages_custom_column', 'ssid_value', 10, 2);
add_filter('manage_media_columns', 'ssid_column');
add_action('manage_media_custom_column', 'ssid_value', 10, 2);
add_filter('manage_link-manager_columns', 'ssid_column');
add_action('manage_link_custom_column', 'ssid_value', 10, 2);
add_action('manage_edit-link-categories_columns', 'ssid_column');
add_filter('manage_link_categories_custom_column', 'ssid_return_value', 10, 3);
foreach ( get_taxonomies() as $taxonomy ) {
add_action("manage_edit-${taxonomy}_columns", 'ssid_column');
add_filter("manage_${taxonomy}_custom_column", 'ssid_return_value', 10, 3);
}
add_action('manage_users_columns', 'ssid_column');
add_filter('manage_users_custom_column', 'ssid_return_value', 10, 3);
add_action('manage_edit-comments_columns', 'ssid_column');
add_action('manage_comments_custom_column', 'ssid_value', 10, 2);
}
add_action('admin_init', 'ssid_add');
专业提供WordPress主题安装、深度汉化、加速优化等各类网站建设服务,详询在线客服!