Skip Navigation

[Resolved] Exclude specific posts on Google Maps – selection by checkbox

This support ticket is created 4 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 1 reply, has 2 voices.

Last updated by Jamal 4 years, 4 months ago.

Assisted by: Jamal.

Author
Posts
#1959119
Screenshot 2021-02-20 at 00.19.36.png

Hi,
I have created a map of a range of schools, which are members of the organization I am working for. It works fine, but I need to hide 3-5 of the schools on the map view, since they are abroad from Denmark, which makes the map zoom out immensely. I have created a checkbox in the post type: "Vis ikke på kort" (meaning "Don't show on map" in Danish) - how do i exclude these entries, without removing them entirely from the list?

See the page in question here: hidden link

All the best,
Mikkel from Denmark

#1959803

Hello Mikkel and thank you for contacting the Toolset support.

Currently, with the Blocks editor, a map can get markers from a view. There is no way to exclude posts from the view's results inside the map.

But, I run a small test locally and I was able to exclude a post, using a conditional block, from the map. I used shortcodes to add the marker to the map instead of configuring the map block to pull markers from the view.

The trick is to add an empty map, without any markers. Check this screenshot hidden link
Then, inside the view's loop, I used a conditional block, you can set the condition on the checkbox field. Then, I add the marker to the map using a shortcode inside of a "Fields&Text" block. Check this screenshot hidden link

The map shortcode needs to use the map's ID. My map's ID is "map-4", and the address field has the slug "location", the shortcode is then:

[wpv-map-marker map_id='map-4' marker_id='marker-[wpv-post-id]' marker_field='wpcf-location'][/wpv-map-marker]

Notice how I used the map's ID in map_id='map-4'  and I prefixed the field slug with "wpcf-" in marker_field='wpcf-location'.

Read more about the Toolset Maps shortcodes here https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-marker

Does it make sense? Let me know if you have any questions.