Skip Navigation

[Resolved] Create link to google maps from address field

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

Problem: I would like to create an external link to the Google Maps site that loads a map to an address stored in a custom address field.

Solution: Use the following custom code to create a custom link tag:

<a href="https://www.google.com/maps/place/[types field='direccion_comercio' output='raw'][/types]/" title="IR AL COMERCIO">IR AL COMERCIO</a>

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/

This support ticket is created 3 years, 5 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)

This topic contains 6 replies, has 2 voices.

Last updated by Christian Cox 3 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#1852271

How can you put the field address as a link to open it in google maps

Could you help me?

Thanks

#1852625

Hello, you can use a Types field shortcode to create a custom HTML link tag like this:

<a href='<em><u>hidden link</u></em> field="book-location" output="raw"][/types]/' title='Go there'>Go there</a>

You can place that code in a post, a template for that post, or in a View's loop editor, using a custom HTML block if you're using the Block editor.

#1852669

Where do I have to create the shortcode?

If I put it in the content template it takes me to google maps but no address

1
<a href='<em><u>hidden link</u></em> field="direccion_comercio" output="raw"][/types]/' title='Go there'>IR AL COMERCIO</a>

hidden link

#1852741

If the address field is in a post, and you apply the Content Template to the same post, it should work automatically. For example, if the address field is in the post type "Locations" and you place this shortcode in the Content Template applied to Locations posts, the shortcode should work automatically. If the Content Template is assigned to a different post, I would need to know more about where the address field is found in relation to the other post.

If you provide logins I can take a closer look. Let me know where to find the link on your site.

#1852751
Screen Shot 2020-11-22 at 1.13.48 PM.png

Check now, I adjusted the code as follows:

<a href="<em><u>hidden link</u></em> field='direccion_comercio' output='raw'][/types]/" title="IR AL COMERCIO">IR AL COMERCIO</a>

There was a problem with some of the double quotation marks in the block editor converted to

&quot;

Seems to be working now.

#1852765

Greatful!

Thanks Christian 🙂

#1852779

No problem, glad it's working!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.