有时我们需要在wordpress后台编辑特定的文章,找了大半天眼睛都花了,不禁会吐槽一下。有没有什么办法可以直接在日志列表查看日志 ID 呢?我们可以通过下面的代码实现:
<?php
/*
Plugin Name: 在后台显示日志 ID
Plugin URI: http://blog.wpjam.com/m/how-to-display-post-id-in-the-wordpress-admin/
Description: WordPress 技巧:如何在后台显示日志 ID
Version: 0.1
Author: Denis
Author URI: http://blog.wpjam.com/
*/
add_filter('manage_posts_columns', 'wpjam_id_manage_posts_columns');
add_filter('manage_pages_columns', 'wpjam_id_manage_posts_columns');
function wpjam_id_manage_posts_columns($columns){
$columns['post_id'] = 'ID';
return $columns;
}
add_action('manage_posts_custom_column','wpjam_id_manage_posts_custom_column',10,2);
add_action('manage_pages_custom_column','wpjam_id_manage_posts_custom_column',10,2);
function wpjam_id_manage_posts_custom_column($column_name,$id){
if ($column_name == 'post_id') {
echo $id;
}
}
可以单独保存成插件的形式
参考自我爱水煮鱼
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有