1

I have tried to get 2 different posts having the values in $al. I can retrieve the posts one at a time but fail to get both together:

$al = array('51.66963','51.60652');

$meta_query[] =  array(
  'meta_query' => array(
   'relation'  => 'AND',
    array(
        'key'     => 'estate_property_google_maps',
        'value'   => $al['0'],
        'compare' => 'LIKE',
    ),
),
  array(
      'key'       => 'estate_property_google_maps',
      'value'       => $al['1'],
      'compare'       => 'LIKE',
      ),
);
3
  • You have key three times in the second array and incorrectly closed arrays.
    – birgire
    Commented Dec 12, 2015 at 14:12
  • @birgire edited :) Commented Dec 12, 2015 at 14:35
  • What is the format of the data stored under the estate_property_google_maps key?
    – s_ha_dum
    Commented Dec 12, 2015 at 15:48

1 Answer 1

1

Shouldn't it be like this (doc)?

$meta_query[] = array( 'meta_query' => array(
    'relation' => 'AND',
    array(
        'key'     => 'estate_property_google_maps',
        'value'   => $al['0'],
        'compare' => 'LIKE'
    ),
    array(
      'key'       => 'estate_property_google_maps',
      'value'       => $al['1'],
      'compare'       => 'LIKE'
    ),
) );
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.