有时我们需要查看某篇文章或者分类的 ID,需要将鼠标放在文章或者分类名称上,然后查看浏览器状态栏上链接中的数字才能获得 ID 号,不够直观,可以将下面的代码添加到当前主题 functions.php 文件中,之后s , W会在后台文章、分类等列表后面直接显示 In J 5 p Q 0 RD 号:
- // Prepend t, u x ? s ( 2 S bhe new column to the columns array
- function ssid_column($cols) {
- $cols['ssid'] = 'ID';
- return $cols;
- }$ n z
- // Echo the ID for the new column
- function ssid_value($column_name, $id) {
- if ($column_name == 'ssid')
- echo $id;
- }
- function ssid_return_value($I A \ { 4 @ * hvalue, $coluf ; $ Nmn_name, $id) {
- if ($column_name == 'ssid')
- $value = $id;
- return $value;
- }
- // OutZ H . W 6 H 0 ^ (put CSS for width of n\ i 6 @ p X mew column
- function ssid_css()+ f _ w w ( {
- ?>
- <style type=&quoO 0 k E f J n Y zt;text/css">
- #ssidC E @ 2 2 ~ 0 B { width: 50px; } /* Simply Show IDs */
- &l2 i w #t;/B A J r ~ 5 Zstyle>
- <?php
- }
- // Actions/Filters for various tables and the css output. Z S J i _ Q .
- function ssW 9 4 H F A m Kid_add() {
- add_action('admin_head', 'ssq = kid_css');
- add_filter('manage_posts_columns', 'ssid_column');Y l _ [ x ? o o
- add_action('manage_posts_custom_column', 'ssid_value', 10, 2);
- add_filter('manage_pages_columns', 'ssid_column');
- add_actionc ~ 4 k Y _40;'manage_pages` T {_custom_column', 'ssid_value', 10, 2);
- add_filter('manage_media_columns', 'ssid_column');
- add_action('manage_media_custom[ t 9 (_column', 'ssid_value', 10, 2J \ $41;;
- add_filter('manage_link-manager_columns', 'ssid_column');
- add_action('manage_link_custom_column', 'e % P ( M Vssid_] j 0va; g 4 % h ! :lue', 10, 2);
- add_action('manage_edit-link-categories_columns', 'ssiz i Q n B r Xd_coM e g m Q $lumn');
- add_filter('manage_link_categorie: \ 7 C Vs_custom_column', 'ssid_return_value', 10,& ~ b / A s 3);
- foreach ( get_taxonomies() as $taxonomy ) {
- addv V 7 F N R w ?_action("manage_edit-${taxoI O K pnomy}_columns", 'ssiP | F | id_column');
- add_filter(&quo7 T d Ht;manage_${taxono1 m = m Vmy}_custom_column", 'ssid_returr i T + an_value', 10, 3] , N | o : U41;;
- }
- add_action('manage_users_columns', 'ssid_column');
- add_; U i 8 H \ H H =filter('manage_users_custom_column', 'ssid_return_va9 . T ( r { n I zlue', 10, 3x O y Y a K41;;
- add_action('manage_edit-comments_columns', 'ss9 { O ) \ ) mid_column');
- add_action('manage_comments_custom_column', 'ssid_value'T / d \ ( 8 \ V Y, 10, 2);= m X b C M
- }
- add_action('a4 { \ R \ f ndmin_init',d G g 0 8 'ssid_add');
代码来自插件:Simply Show IDL t @ ! a Ls