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( 
                         'key' => 'state', 
                         'value' => 'Texas', 
                          '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.