Home › Forums › MapPress Support › Mashup with Tax Query
Tagged: Mashup with Tax Query & Array
- This topic has 4 replies, 2 voices, and was last updated 13 years ago by
utcommoffice.
-
AuthorPosts
-
November 6, 2013 at 2:42 pm #13695
My custom query parameters are:
$parentID from main Loop 1
$args2 = array (
'post_type' => 'location',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'area',
'field' => 'term_id',
'terms' => $parentID
))
);How can i create a mashup of the resulting posts ? Each posts has a map generated via custom_fields. I have the IDs stored in an array $locationID. I’ve tried it via php and via shortcode, both only show 1 location.
It works when i do it manually:
$mymap = new Mappress_Map(array( "width" => 800, "height" => 800 )); $mymap->pois = array($mypoi[0], $mypoi[1]); echo $mymap->display();What I am trying to do is automate the second part:
$mymap->pois = array($collectedpoiarray);or
do shortcode('[mashup query="'.$locationID.'"]');November 7, 2013 at 4:26 am #13699Hi,
You can include your query in the map, for example:
$query = array ( 'post_type' => 'location', 'posts_per_page' => -1, 'tax_query' => array( array( 'taxonomy' => 'area', 'field' => 'term_id', 'terms' => $parentID )) ); $map = new Mappress_Map(); $map->query = $query; $map->display(array('width' => 800, 'height' => 800));November 8, 2013 at 3:47 am #13708Thank you Chris. How would this be done if i were using a [mashup] shortcode ?
November 8, 2013 at 4:13 am #13709There is no way to substitute variables (like $parentID) in a shortcode entered in the WordPress post editor.
If you use PHP, another way to create the map is to use the do_shortcode() command.
Assuming that $parentID is the slug for a term in the ‘area’ taxonomy you could write:
$query = “post_type=location&posts_per_page=-1&area=” . $parentID;
do_shortcode(‘[mashup query="' . $query . '"]‘);There are some other query string examples for custom taxonomies in the plugin documentation.
November 18, 2013 at 5:17 am #13782Sweet. Thank you Sir !
-
AuthorPosts
- You must be logged in to reply to this topic.
