211 posts Devil Can't Burn
  • Has referred 50+ members
  • Has sold $250,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+8 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
  • Has referred 50+ members
  • Has sold $250,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+8 more
Devilcantburn says

No body knows….

Please wp coders… help me ! :)

1497 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+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
  • Has referred 50+ members
  • Has sold $250,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+8 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?

1497 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+2 more
OriginalEXE says

I do :)

'meta_query' => array(
       array(
           'key' => 'mykey',
           'value' => $mykey,
           'compare' => 'IN',
       )
   )
211 posts Devil Can't Burn
  • Has referred 50+ members
  • Has sold $250,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+8 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 )

1497 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+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