How to Ordering by user meta
-
I am learning WordPress meta query. I am trying to fetch users with
asc
order oflast_name
&first_name
. My code is like below.if($_POST['orga_id']) { $users_query = array( 'meta_query' => array( 'relation' => 'AND', array( 'relation' => 'OR', array( 'key' => 'first_name', 'value' => $_POST['search'], 'compare' => 'LIKE' ), array( 'key' => 'last_name', 'value' => $_POST['search'], 'compare' => 'LIKE', ), ), array( 'key' => 'organisation', 'value' => $_POST['orga_id'], 'compare' => 'LIKE', ), array( 'key' => 'available', 'value' => 1, 'compare' => '=', ), ) ); } else { $users_query = array( 'meta_query' => array( 'relation' => 'AND', array( 'relation' => 'OR', array( 'key' => 'first_name', 'value' => $_POST['search'], 'compare' => 'LIKE' ), array( 'key' => 'last_name', 'value' => $_POST['search'], 'compare' => 'LIKE', ), ), array( 'key' => 'available', 'value' => 1, 'compare' => '=', ), ) ); }
How can I fetch users with
asc
order oflast_name
&first_name
?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘How to Ordering by user meta’ is closed to new replies.