Home › Forums › General Issues › How to sort by ACF field › Reply To: How to sort by ACF field
Hi,
in your $args you can’t add multiple ‘meta_key’ => ‘…’, ‘meta_value’=>’…’ on the same level.
you will want to replace your meta_key
and meta_value
entry by a multiple array:
$args = array(
'some_args' => 'some value,
'meta_query' => array(
array(
'key' => 'state',
'value' => 'Texas',
),
array(
'Key' => 'city',
'value' => 'Houston'
),
'some_other_args' => 'some_value'
);
This should get you the state of Texas and the city of Houston with all the other args you have defined.
you may want to use variable on your states and city value.
I haven’t tested this code so let me know how it goes.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.