i have a meta key and i want to perform a check on meta values , lets say i have meta key 'organisation' and values can be like of two cases:

  1. Some text here like a title. ( meta value for key 'organisation')
  2. some-text-here-like-a-slug. ( meta value for key 'organisation')

i want to fetch posts that have either match one of these meta values.

i have this code

$args = array( 
  'post_type' => 'post', 
  'posts_per_page' => 10,
  'order_by'  => 'ASC',
  'meta_query' => array(
    'relation' => 'OR',
        'key' => 'organisation', //for the same meta key ???
        'value' => 'slug-here',
        'compare' => '='
        'key' => 'organisation', //for the same meta key ???
        'value' => 'Title Here',
        'compare' => '='

Please suggest a solution.

  • Does that not work? – Jacob Peattie Dec 14 '17 at 11:25
  • no this does not work – Jay Kapoor Dec 14 '17 at 11:29
  • Verify that you have the meta_key names correct, you have published the post and that the type of the post is actually 'post'. – Drupalizeme Dec 14 '17 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.