Php WordPress中的博客文章作者过滤器
我想把作者过滤器下拉到可湿性粉剂管理后端。如中所示,不仅按类别或标记过滤,还按作者过滤 下面的代码在很大程度上是有效的,但它提供了所有注册用户,包括那些没有作者能力的用户。我想过滤这个列表,只显示非订阅者,但是,作为PHP的新手,我似乎无法理解。要么我破坏了我的网站,要么插入的代码完全不起作用Php WordPress中的博客文章作者过滤器,php,wordpress,list,filter,author,Php,Wordpress,List,Filter,Author,我想把作者过滤器下拉到可湿性粉剂管理后端。如中所示,不仅按类别或标记过滤,还按作者过滤 下面的代码在很大程度上是有效的,但它提供了所有注册用户,包括那些没有作者能力的用户。我想过滤这个列表,只显示非订阅者,但是,作为PHP的新手,我似乎无法理解。要么我破坏了我的网站,要么插入的代码完全不起作用 /** * This section makes posts in the admin filterable by the author. */ add_action('r
/**
* This section makes posts in the admin filterable by the author.
*/
add_action('restrict_manage_posts', 'ditt_filter_by_author');
function ditt_filter_by_author() {
$params = array(
'name' => 'author',
'show_option_all' => 'All Authors'
);
if ( isset($_GET['user']) ) {
$params['selected'] = $_GET['user'];
}
wp_dropdown_users( $params );
}
欢迎使用任何指针。在中使用role\u或role将其限制为特定的用户角色
/**
* This section makes posts in the admin filterable by the author.
*/
add_action('restrict_manage_posts', 'ditt_filter_by_author');
function ditt_filter_by_author() {
$params = array(
'name' => 'author',
'role__in' => array('author','editor','administrator')
);
if ( isset($_GET['user']) ) {
$params['selected'] = $_GET['user'];
}
wp_dropdown_users( $params );
}
这将对其进行过滤,以仅显示作者、编辑和管理员。感谢您的回复。我已经试过了。实际上,它使下拉列表完全消失。我应该提到,我使用的是自定义用户角色,但这并不重要。它应该是一样的。我使用的插件是AAM,调试日志中没有任何东西表明它会干扰。