Is it possible to order custom type posts by user meta? In my custom type posts list, I am showing user name and user phone. I have user id as meta of my post and ordering works for that. However, I dont have user phone as post meta, but rather it is user meta. How can I order my posts by user phone?
Here is the code I am using to order posts by post meta:
function order_columns($vars)
{
if (!is_admin()) {
return $vars;
}
$columns = array(
'user_id',
'expiry_date',
'active',
);
if (isset($vars['orderby']) && in_array($vars['orderby'], $columns)) {
$vars = array_merge($vars, array('meta_key' => $vars['orderby'], 'orderby' => 'meta_value'));
}
return $vars;
}