通常查看日志ID时习惯在后台把鼠标移至文章标题,然后在状态栏获取,或者使用动态URL直接查看,那么是否有更直观的方法像要看文章标题一样查看文章的ID?对此我们可以通过在functions.php文件添加下面的代码实现这个效果!
代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <?php 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; } } ?> |
代码来源:我爱水煮鱼,转载请注明!