现在WordPress开放多用户的网站越来越多,我们要观看了解所有用户发布的文章数量WordPress并不能给我们排序,如果要让WordPress用户列表文章排序就需要添加WordPress用户列表文章排序功能,对今天要讲的是WordPress用户列表文章排序。
把下面的代码丢入您的主题文件functions.php 即可:
WordPress用户列表文章排序
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();
}
添加完以上WordPress用户列表文章排序您的主题就支持WordPress用户列表文章排序了,您可以点击用户的‘文章’就排序。

