默认情况下,wordpress用户查询不允许在搜索列中显示\\u名称,即使已将其添加到中,下面是一个解决方案http://manchumahara.com/2014/04/03/search-user-by-display-name-in-wordpress-sitewide/
示例:
$args= array(
\'search\' => \'Display Name\', // or login or nicename in this example
\'search_fields\' => array(\'user_login\',\'user_nicename\',\'display_name\')
);
$user = new WP_User_Query($args);
上面的查询找不到display\\u name
您需要使用此筛选器
add_filter(\'user_search_columns\', \'user_search_columns_bd\' , 10, 3);
function user_search_columns_bd($search_columns, $search, $this){
if(!in_array(\'display_name\', $search_columns)){
$search_columns[] = \'display_name\';
}
return $search_columns;
}