Mashup with Tax Query

Home Forums MapPress Support Mashup with Tax Query

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #13695
    utcommoffice
    Participant

    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.'"]');

    #13699
    Chris
    Keymaster

    Hi,

    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));
    
    #13708
    utcommoffice
    Participant

    Thank you Chris. How would this be done if i were using a [mashup] shortcode ?

    #13709
    Chris
    Keymaster

    There 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.

    #13782
    utcommoffice
    Participant

    Sweet. Thank you Sir !

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.