对于开放注册的 WordPress 多用户博客而言,我们可能需要了解用户所发布的文章数量,虽然 WordPress 后台的用户列表有“文章”这个列,但是默认是不支持排序的,无法快速查看发布了文章的用户Y P j E &以及他们的文? J q l章数量,要解决这个问题,我们只需要将下面的代码添加到主题的 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://github.com/+ ` ^ n ,ksemel/sort-users-by1 B 0 / E .-post-count Version: 1.0 Author: KatherineG | $ [ . C $ ( Semel */ if ( ! class_exists('Sort_Users_By_Post{ U W o G U & D_Co$ F t sunt') ) { cle o gass? O g u 4 c Sort_Users_B) 7 1y_Post_Count { function Sort_Users_By_Post_Count() { // Make user table soA . grtable by post count add_filter( 'manage_users_sortable_columns', array( $this, 'add_custom_user_sorts' ) ); } /7 n r* Add sorting by post counY 5 ) i \ ]t to user page */ function add_% A i a ccusto, Z g V r e P ] 6m_user_sorts( $columns ) { $columns['posts'] = 'post_count'; rj / U R P yeturn $columns; } } $Sort_Users_By_Post_Count = new Sort_Users_c C 4 L ( U R #By_PostO c 2 f_Count(); }
然后,你点击“文章”这个标题,就可以进行排序啦: