Reply To: Mashup query with two custom fields

Home Forums MapPress Support Mashup query with two custom fields Reply To: Mashup query with two custom fields

#13781
Chris
Keymaster

    Unfortunately, the WP query engine doesn’t provide support for more than one meta value in a query string. Multiple ‘meta_key’ or ‘meta_values’ are ignored (‘meta_value__and’ is also ignored, it’s not a valid keyword).

    One workaround is to use a single value or a taxonomy instead. Or, a ‘save_post’ action can be used to set a single custom field value or category when the post is saved.

    Another option is to create the map using PHP. If the query is passed as an array, WP allows complex mtea queries. You’ll need to add some code to your template:

    <?php
    	$query = array(
    	'post_type' => 'any',
    	'posts_per_page' => -1,
    	'meta_query' => array(
    		array('key' => 'color', 'value' => 'blue'),
    		array('key' => 'size', 'value' => 'large'),
    	)
    );
    $map = new Mappress_Map(array('query' => $query, 'width' => 400, 'height' => 400));
    echo $map->display();
    ?>

    There are some meta query examples here:
    http://codex.wordpress.org/Class_Reference/WP_Query