WordPress的文章后台列表中仅提供了日期、分类目录、文章类型三个简单的筛选条件。当我们想要找出某个用户发布的文章时,WordPress的后台文章列表就无法实现了。今天WordPress主题站为大家分享为WordPress后台文章列表添加作者筛选功能方法。

//WordPress代码实现后台文章列表添加作者筛选功能

add_action(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’restrict_manage_posts\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’author_select\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

function author_select($post_type){

if(post_type_supports($post_type, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’author\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’)){

wp_dropdown_users([

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’name\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’author\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’,

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’who\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’authors\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’,

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’show_option_all\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’所有作者\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’,

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’hide_if_only_one_author\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => true,

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’selected\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => $_REQUEST[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’author\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’] ?? 0

]);

}

}

将上面的代码添加到你WordPress主题的functions.php文件中,刷新所有文章列表,可以看到如下图所示效果。

相关新闻

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

联系我们

联系我们

151-1101-0018

在线咨询:
邮件:30115776@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
关注微信
分享本页
返回顶部