對(duì)于一些多用戶(hù)發(fā)布文章的文章,如何對(duì)這些作者進(jìn)行有價(jià)值的管理是一個(gè)問(wèn)題,
如果wordpress站長(zhǎng)需要了解用戶(hù)所發(fā)布的文章數(shù)量,雖然 WordPress 后臺(tái)的用戶(hù)列表有“文章”這個(gè)列,但是默認(rèn)是不支持排序的,無(wú)法快速查看發(fā)布了文章的用戶(hù)以及他們的文章數(shù)量,這一篇的wordpress教程就能很好的解決這個(gè)問(wèn)題。
- 代碼來(lái)源:Github
將下面的代碼添加到主題根目錄下的 functions.php文件的<?php
下并保存 即可:
//文章數(shù)排序
/*
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();
}
然后,你點(diǎn)擊“文章”這個(gè)標(biāo)題,就可以進(jìn)行排序啦:
