Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Создание колонки "ID"
- add_filter('manage_posts_columns', 'add_id_column', 5);
- add_filter('manage_pages_columns', 'add_id_column', 5);
- function add_id_column($columns) {
- $out = array();
- foreach ($columns as $col => $name) {
- if (++$i == 3) $out['id'] = __('ID');
- $out[$col] = $name;
- }
- return $out;
- }
- // Заполнение колонки "ID" данными
- add_filter('manage_posts_custom_column', 'fill_id_column', 5, 2);
- add_filter('manage_pages_custom_column', 'fill_id_column', 5, 2);
- function fill_id_column($colname, $post_id) {
- if ($colname === 'id')
- echo $post_id;
- }
- // Правка ширины колонки "ID" через CSS
- add_action('admin_head', 'edit_id_column_css');
- function edit_id_column_css() {
- if (get_current_screen()->base == 'edit')
- echo '<style type="text/css"> .column-id { width: 10%; } </style>';
- }
- // Сортировка колонки "ID"
- add_filter('manage_edit-post_sortable_columns', 'edit_id_sortable_column');
- add_filter('manage_edit-page_sortable_columns', 'edit_id_sortable_column');
- function edit_id_sortable_column($sortable_columns) {
- $sortable_columns['id'] = 'id_id';
- return $sortable_columns;
- }
Add Comment
Please, Sign In to add comment