Home › Forums › MapPress Support › Automatically apply a map filter using a URL or Query String › Reply To: Automatically apply a map filter using a URL or Query String
Thanks for your help.
I have tried that and it works for a single filter. But once I have done that I can’t use the filters on the map on the front end.
To give you more context…
My setup:
– I have a Mashup map displaying all ‘location’ posts (custom posts)
– I have a ‘location_type’ custom taxonomy set on ‘location’ posts
– My map has a filter setup in the MapPress plugin settings using location_types as check boxes
– I can filter the locations posts using the map filter UI on the location_types – this is all working really well
What I’d like to do is:
– apply a filter to the map from the URL
– see the filter appplied to the map on the filter UI
– change the map filter using the filter UI to a different filter
This is where I am at:
I am using a URL /map/?location_type=cafe-shop
my PHP is
if ( get_query_var('location_type') ) {
$filter = get_query_var('location_type');
echo do_shortcode('[mashup query="post_type=location&location_type=' . $filter. '"]');
}
The map filters by ‘cafe-shop’ as expected.
Issues:
– The filter list on the UI does not have ‘cafe-shop’ selected
– If I try to change the filter to something else usising the UI, the filter does not work, it stays on ‘cafe-shop’
Is there a way of pre-filtering the map and then allowing the user to interact with the filters?
Thanks
