I’m trying to create a filter using two meta_values.
Example.
If the current page has meta values red and blue, only display queried pages that have both red and blue and none that have just red or just blue.
I thought this could be accomplished with two meta values 'meta_value' => $red, $blue
but apparently it’s not available. Below is where I found myself before the block. I’ve done a ton of research and simply can’t find a method that works. Any help would be appreciated.
$red = get_post_meta($post->ID, 'red', true);
$blue = get_post_meta($post->ID, 'blue', true);
$args = array(
'post_type' => page,
'nopaging' => true,
'post_parent' => 1440,
'meta_value' => $red, $blue
);
query_posts($args);
‘meta_query’ is what you’re looking for:
http://scribu.net/wordpress/advanced-metadata-queries.html
I think this should work if you wrap it in an array? Not entirely sure, though … ‘meta_value’ => array(‘red’, ‘blue’).