当我们的站点内有多用户发布文章时,为了方便管理员查看某位作者的文章列表,我们可以在后台文章列表添加一个作者筛选的选项功能,。
该功能添加的方式也很简单,添加下方代码到主题的functions.php文件中。
add_action('restrict_manage_posts', function($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 ]); } });
该功能已经整合到 WPJAM Basic 插件中,并已免费提供下载!