• Julian Chaniolleau

    (@devilcantburn)


    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

    [No bumping. If it’s that urgent, consider hiring someone.]

Viewing 2 replies - 1 through 2 (of 2 total)
  • vtxyzzy

    (@vtxyzzy)

    This may be what you want:

    'meta_query' => array(
        'relation' => 'OR',
        array(
            'key' => 'mykey',
            'value' => $mykey,
            'compare' => 'IN'
        ),
    )
    Thread Starter Julian Chaniolleau

    (@devilcantburn)

    Yes thank you vtxyzzy !
    exactly that!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘WP: multiple meta_query from array’ is closed to new replies.