You can do it like so:
-
Use the
manage_<screen ID>_columnsfilter to add the “ID” column.Example for the default
categorytaxonomy where<screen ID>isedit-category— for other taxonomies, it would beedit-<taxonomy>likeedit-post_tag:add_filter( 'manage_edit-category_columns', 'my_manage_edit_category_columns' ); function my_manage_edit_category_columns( $columns ) { // Add the "ID" column. $columns['term_id'] = 'ID'; // .. add other columns, if you want to. return $columns; } -
Use the
manage_<screen ID>_sortable_columnsfilter to make the “ID” column be sortable.Example for the default
categorytaxonomy (the screen ID format is the same as above):add_filter( 'manage_edit-category_sortable_columns', 'my_manage_edit_category_sortable_columns' ); function my_manage_edit_category_sortable_columns( $sortable_columns ) { // Add the "ID" column. $sortable_columns['term_id'] = 'term_id'; // .. add other columns, if you want to. return $sortable_columns; } -
Use the
manage_<taxonomy>_custom_columnfilter to display the actual term ID in the “ID” column.Example for the default
categorytaxonomy:add_filter( 'manage_category_custom_column', 'my_manage_category_custom_column', 10, 3 ); function my_manage_category_custom_column( $content, $column_name, $term_id ) { switch ( $column_name ) { case 'term_id': $content = $term_id; break; } return $content; }
That’s all, but for sorting by other fields than the term_id, you would need to manually filter the terms query args, e.g. using the get_terms_args filter or the parse_term_query action.