Reply To: Mash Up map from different CPT

Home Forums MapPress Support Mash Up map from different CPT Reply To: Mash Up map from different CPT

#14387
Chris
Keymaster

Hi,

There’s no way to geocode using different fields. You’ll need to find a way to get all the data into one field (such as ‘address’). You could do that with some PHP.

The ‘save_post’ action might work as a place to copy from one field to another. Here’s an (untested) example:


function mysavepost($post_id, $post) {
  if ($post->post_type == 'tours')
    $loc = get_post_meta($post_id, 'tour-location', true);
  else if ($post->post_type == 'attraction')
    $loc = get_post_meta($post_id, 'attraction-address', true);
  endif;
  
  if ($loc)
    update_post_meta($post_id, 'address', $loc);
  else 
    delete_post_meta($post_id, 'address);
}

add_action('save_post', 'mysavepost', 100, 2);

MapPress doesn’t yet support filtering (where you check boxes). You can control what is shown by using different categories on the posts and presenting different maps (i.e. a map for category A and a different map for category B).