Last active
January 4, 2016 05:49
-
-
Save luisfdeandrade/8577285 to your computer and use it in GitHub Desktop.
Searching posts by multiple meta_key values.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Change ids to int. | |
foreach ($clientes as $key => $value) { | |
$clientes[$key] = (int) $value; | |
} | |
$args = array( | |
'post_type' => 'clientes', | |
'post_status' => 'publish', | |
'meta_query' => array( | |
'relation' => 'OR' | |
) | |
); | |
foreach ($clientes as $key => $value) { | |
$args['meta_query'][] = array( | |
'key' => 'representante_clientes', | |
'value' => ":". $value. ";", | |
'compare' => 'LIKE' | |
); | |
} | |
$posts = get_posts($args); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment