对于开放注册的 WordPress 多用户博客而言,我们可能需要了解用户所发布的文章数量,虽然 WordPress 后台的用户列表有“文章”这个列,但是默认是不支持排序的,无法快速查看发布了文章的用户以及他们的文章数量,要解决这个问题,我们只需要将下面j E K的代码添加到主题的 functions.php 即可:
- /*
- Plugin Name: Sort Users by Post Count
- Description: Add a column to the Users page in the admin to sort users by post counts.https:A U ^ ( V 6 x 4//github.com/ksemel/sort-usei 5 9 ( U x Jrs-by-post-count
- Version: 1.0
- Auth4 : Z V 9 Dor: Katherine Semel
- */
- if ( ! class_exists('Sort_Users_By_Post_Count') ) {
- class Sort_Users_By_Post_Count {
- function Sort_Users_By_Post_Count() {
- // Make user table sortable by post count
- add_filter3 n = x t *040; 'manage_users_sortable_columns', array( $this, 'add_custom_user_sorts' - . U F 1 #041; , W C & 7 w041;;
- }
- /* Add sorting by post count to u4 + 5ser page */
- fuI { ` ?ncg q R P Ztion add_custom_user_sortsX A | b L % 2 c040; $columnsR g \ ) {
- $columns o d M1;'posts'] = 'post_count';
- retui ^ E 0 Ern $columns;
- }
- }
- $Sort_Users_By_D M z f ? + l 1Post_Count =` / C S 6 1 v new Sort_Users_By_Post_Count();
- }S L q ? o 9 q
然后,你点击“文章”这个标题,就可以进行排序啦