Nếu như sinh nhật không phải là một giá trị mà phân làm 3 thì chúng ta có thể sắp xếp theo năm, tháng và ngày.
$orderby = $_GET['orderby'] ?? '';
if ( 'birthday' == $orderby ) {
$order = $_GET['order'] ?? 'ASC';
//$query->set( 'order', $order );
$query->set( 'meta_query', array(
'relation' => 'AND',
'birth_year' => array(
'key' => 'birth_year',
'compare' => 'EXISTS'
),
'birth_month' => array(
'key' => 'birth_month',
'compare' => 'EXISTS'
),
'year_day' => array(
'key' => 'birth_day',
'compare' => 'EXISTS'
)
) );
$query->set( 'orderby', array(
'birth_year' => $order,
'birth_month' => $order,
'birth_day' => $order
) );
}