如何更改作者列表页面中作者的顺序
发表于 : 2024年 4月 18日 09:29
Jannah 使用标准的 WordPress get_users 函数,该函数按用户登录名的字母顺序对作者进行排序,该函数支持以下字段对作者进行排序
ID
display_name
user_login
user_nicename
user_email
user_url
user_registered
post_count
例如,按作者发布的文章数对“作者列表”页面中的作者进行排序。将此代码添加到子主题的文件中,或通过允许添加自定义函数的插件(例如Code snippets插件)添加。避免将自定义代码直接添加到父主题的文件中,因为当您更新主题时,这将被完全擦除。functions.php
ID
display_name
user_login
user_nicename
user_email
user_url
user_registered
post_count
例如,按作者发布的文章数对“作者列表”页面中的作者进行排序。将此代码添加到子主题的文件中,或通过允许添加自定义函数的插件(例如Code snippets插件)添加。避免将自定义代码直接添加到父主题的文件中,因为当您更新主题时,这将被完全擦除。functions.php
代码: 全选
add_filter( 'TieLabs/Page_Template/Authors/args', 'custom_chnage_authors_order' );
function custom_chnage_authors_order( $args ){
$args['orderby'] = 'post_count';
$args['order'] = 'DESC';
return $args;
}