Last active
March 8, 2023 16:44
-
-
Save snrjosh/999ee5486861428c5ee504c6cfa098a7 to your computer and use it in GitHub Desktop.
Order posts by multiple ACF fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$args = array( | |
'meta_query' => array( | |
'meta_key_1' => array( | |
'key' => 'product_price', // field_name_1 | |
'value' => array( 500, 1000 ), | |
'type' => 'numeric', | |
'compare' => 'BETWEEN', | |
), | |
'meta_key_2' => array( | |
'key' => 'product_type', //field_name_2 | |
'compare' => 'EXISTS', | |
), | |
), | |
'orderby' => array( | |
'meta_key_1' => 'ASC', | |
'meta_key_2' => 'DESC', | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment