Skip Navigation

[Resolved] Conditionally display content based on geographic location

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to display content conditionally, based on a visitor's location.

Solution: Add a custom address field to the custom post type, and then create a View filtered by distance from the User's location.

Relevant Documentation: https://toolset.com/documentation/user-guides/display-on-google-maps/filtering-and-ordering-map-markers-by-distance/

This support ticket is created 5 years, 9 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1198170

Tell us what you are trying to do?

I'd like to be able to conditionally display content based on a visitor's geographic location.

I'm building a directory of medical professionals and would like to display a doctor's or multiple doctor profiles at the bottom of a blog article with the heading "Doctors Near You".

Is there any documentation that you are following?

No.

Is there a similar example that we can see?

hidden link

What is the link to your site?

hidden link

#1198267

Hi, it sounds like you need a View filtered by distance from the current User's location. In general, you will create a custom address field and apply it to the Doctors post type. In the Doctor post editor, you can add an address for each Doctor. Then you can create a View of Doctors filtered by distance from the address field. To filter by distance from the current User's location, your site must be on https and your site visitors must allow you to access their browser location. A popup notification will be displayed to confirm that permission.

We have documentation for distance filters available here: https://toolset.com/documentation/user-guides/display-on-google-maps/filtering-and-ordering-map-markers-by-distance/

Let me know if there's something specific you need assistance with, or if things don't seem to be working as expected.

#1246848

My issue is resolved now. Thank you!