211 posts Devil Can't Burn
  • Envato Studio (Microlancer) Beta Tester
  • Elite Author
  • Exclusive Author
  • Has been a member for 5-6 years
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
  • Sold between 250 000 and 1 000 000 dollars
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+3 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
  • Envato Studio (Microlancer) Beta Tester
  • Elite Author
  • Exclusive Author
  • Has been a member for 5-6 years
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
  • Sold between 250 000 and 1 000 000 dollars
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+3 more
Devilcantburn says

No body knows….

Please wp coders… help me ! :)

1452 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
  • Croatia
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
  • Envato Studio (Microlancer) Beta Tester
  • Elite Author
  • Exclusive Author
  • Has been a member for 5-6 years
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
  • Sold between 250 000 and 1 000 000 dollars
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+3 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?

1452 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
  • Croatia
OriginalEXE says

I do :)

'meta_query' => array(
       array(
           'key' => 'mykey',
           'value' => $mykey,
           'compare' => 'IN',
       )
   )
211 posts Devil Can't Burn
  • Envato Studio (Microlancer) Beta Tester
  • Elite Author
  • Exclusive Author
  • Has been a member for 5-6 years
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
  • Sold between 250 000 and 1 000 000 dollars
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+3 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 )

1452 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
  • Croatia
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