我有这个代码,它工作得很好,但它没有排序。
$args = array(
\'meta_key\' => \'pw_user_status\',
\'meta_value\' => \'approved\',
);
$users = get_users( $args );
我尝试使用下面的方法对结果进行排序,但没有成功。。。
$args = array(
\'meta_query\' => array(
array(
\'key\' => \'pw_user_status\',
\'value\' => \'approved\' ,
),
),
\'orderby\' => \'meta_value\',
\'meta_key\' => \'user_lastname\',
\'order\' => \'ASC\'
);
$users = get_users( $args );
SO网友:G-J
应该是\'meta_key\' => \'last_name\'
而不是\'meta_key\' => \'user_lastname\'
$args = array(
\'meta_query\' => array(
array(
\'key\' => \'pw_user_status\',
\'value\' => \'approved\' ,
),
),
\'orderby\' => \'meta_value\',
\'meta_key\' => \'last_name\',
\'order\' => \'ASC\'
);
$users = get_users( $args );