我刚刚更新到WP 4.1,我使用的User\\u查询现在返回0,而不是预期的结果。
$pm = array(
//\'role\' => \'program_manager\',
\'orderby\' => \'display_name\',
\'meta_query\' => array(
\'relation\' => \'OR\',
array(
\'key\' => $staff_role,
\'value\' => \'program_manager\',
\'compare\' => \'LIKE\'
),
array(
\'key\' => $staff_role,
\'value\' => \'administrator\',
\'compare\' => \'LIKE\'
)
)
);
此函数已插入到
new WP_User_Query()
返回具有自定义角色的所有用户
Program Manager
或
Administrator
随后显示在页面上。如果我删除
meta_query
只需查询
program_manager
角色,然后它可以正常工作,但我仍然需要将管理员包括在此计数中。发生了什么变化?
SO网友:CiprianD
抄本:Multiple custom user fields handling
$args = array(
\'meta_query\' => array(
\'relation\' => \'OR\',
0 => array(
\'key\' => \'country\',
\'value\' => \'Israel\',
\'compare\' => \'=\'
),
1 => array(
\'key\' => \'age\',
\'value\' => array( 20, 30 ),
\'type\' => \'numeric\',
\'compare\' => \'BETWEEN\'
)
)
);
尝试添加0=>数组和1=>数组