对于开放注册的 WordPress 多用户博客而言,我们可能需要了解用户所发布的文章数量,虽然 WordPress 后台的用户列表有“文章”这个列,但是默认是不支持排序的,无法快速查看发布了文章的用户以及他们的文章数量,要解决这个问题,我们只需要将下面的代码添加到主题的 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/ksemel/sort-users-by-post-count
Version: 1.0
Author: 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_filter( 'manage_users_sortable_columns', array( $this, 'add_custom_user_sorts' ) );
}
/* Add sorting by post count to user page */
function add_custom_user_sorts( $columns ) {
$columns['posts'] = 'post_count';
return $columns;
}
}
$Sort_Users_By_Post_Count = new Sort_Users_By_Post_Count();
} |
/*
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/ksemel/sort-users-by-post-count
Version: 1.0
Author: 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_filter( 'manage_users_sortable_columns', array( $this, 'add_custom_user_sorts' ) );
}
/* Add sorting by post count to user page */
function add_custom_user_sorts( $columns ) {
$columns['posts'] = 'post_count';
return $columns;
}
}
$Sort_Users_By_Post_Count = new Sort_Users_By_Post_Count();
}
然后,你点击“文章”这个标题,就可以进行排序啦:

来源:
https://www.wpdaxue.com/wordpress-sort-users-by-post-count.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_32384.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57