211 posts Devil Can't Burn
  • Affiliate Level 3
  • Author Level 9
  • Beta Tester
  • Collector Level 2
+10 more
Devilcantburn
says

Hello,

I wasted some hours on that…. to know how can i get multiple meta_query like :


'meta_query' => array(
    'relation' => 'OR',
    array(
        'key' => 'mykey',
        'value' => 'value1',
        'compare' => '='
    ),
    array(
        'key' => 'mykey',
        'value' => 'value2',
        'compare' => '='
    ),
)
from a simple array like :

$mykey = array( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 );

I need to generate the meta_query automatically because the array is not always the same. Thank you by advance! Julian

211 posts Devil Can't Burn
  • Affiliate Level 3
  • Author Level 9
  • Beta Tester
  • Collector Level 2
+10 more
Devilcantburn
says

No body knows….

Please wp coders… help me ! :)

1565 posts
  • Affiliate Level 1
  • Author Level 5
  • Collector Level 2
  • Featured Author
+2 more
OriginalEXE
says

Are you trying to display all posts that have value under certain meta key, and that value should be one of the values in the array you provide?

211 posts Devil Can't Burn
  • Affiliate Level 3
  • Author Level 9
  • Beta Tester
  • Collector Level 2
+10 more
Devilcantburn
says

Are you trying to display all posts that have value under certain meta key, and that value should be one of the values in the array you provide?

Yes !!

Do you have a solution?

1565 posts
  • Affiliate Level 1
  • Author Level 5
  • Collector Level 2
  • Featured Author
+2 more
OriginalEXE
says

I do :)

'meta_query' => array(
       array(
           'key' => 'mykey',
           'value' => $mykey,
           'compare' => 'IN',
       )
   )
211 posts Devil Can't Burn
  • Affiliate Level 3
  • Author Level 9
  • Beta Tester
  • Collector Level 2
+10 more
Devilcantburn
says

I do :)
'meta_query' => array(
       array(
           'key' => 'mykey',
           'value' => $mykey,
           'compare' => 'IN',
       )
   )

Yeah OriginalEXE! thank you ! that worked !

now…. i’m happy! ( and i can go to sleep :D )

1565 posts
  • Affiliate Level 1
  • Author Level 5
  • Collector Level 2
  • Featured Author
+2 more
OriginalEXE
says

Yeah OriginalEXE! thank you ! that worked ! now…. i’m happy! ( and i can go to sleep :D )

My pleasure ;)

by
by
by
by
by
by