You can use a meta_query
in addition to your tax_query :
https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
I have in which if
statement you want to use it so I put it in the of the code.
$names = array(
'fields' => 'names'
);
$prac_names = get_terms('attorney-practice', $names);
$prac_matches = array_shift(preg_grep ('('. $search .')', $prac_names));
$off_names = get_terms('office-location', $names);
$off_matches = array_shift(preg_grep('('. $search .')', $off_names));
if(in_array($prac_matches, $prac_names)) {
$args = array(
'post_type' => 'employee',
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'attorney-practice',
'field' => 'name',
'terms' => $prac_matches
)
)
);
}elseif(in_array($off_matches, $off_names)) {
$args = array(
'post_type' => 'employee',
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'office-location',
'field' => 'name',
'terms' => $off_matches
)
)
);
}
// Here you add your meta_query to get the value from post_meta
$args['meta_query'] => array(
array(
'key' => 'wpcf-last-name',
'value' => 'YOUR VALUE',
'compare' => 'LIKE',
),
);
// Then you set the order with your
$args['orderby'] => 'meta_value',
$args['order'] => 'DESC'
$query = new WP_Query( $args );
Hope it helps 🙂