Skip Navigation

[Resolved] Display map on page with php

This support ticket is created 5 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.

Our next available supporter will start replying to tickets in about 1.36 hours from now. Thank you for your understanding.

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: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by simoneM-5 5 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1277089

Hi, I need to display the map for my custom post. I created the render field and it works fine, but when I call the field:
<?php echo types_render_field( 'indirizzo') ?> it show me only the string of address and not the map.
How can display it?

#1277119

Hello,

How do you setup the custom field "indirizzo"? is it a custom address field?
If it is, please check our document:
https://toolset.com/documentation/customizing-sites-using-php/functions/#address

The codes you mentioned above will render the address value in string, they won't render the google map or map markers.

In your case, I suggest you create a content template:
https://toolset.com/documentation/user-guides/view-templates/

Put the maps shortcode and marker shortcode into above content template:
https://toolset.com/documentation/user-guides/maps-shortcodes/#wpv-map-render
https://toolset.com/documentation/user-guides/maps-shortcodes/#wpv-map-marker

And render the content template with PHP function render_view_template():
https://toolset.com/documentation/programmer-reference/views-api/#render_view_template

#1277143

Ok, thanks, I read all about it, but I created my custom template in php, without the view plug-in.
There's a way to show map without using view and shortcode?

#1277179

Since you are going to display the google map in your website, the map and marker shortcodes are required in your case, you can try with WordPress function do_shortcode() to render those shortcodes, see WordPress document:
https://developer.wordpress.org/reference/functions/do_shortcode/

#1278213

Thanks, I follow this step and it works fine.

Display a map with a marker for a single item:
1. Add an Address field to the content-type that needs to display an address on the map.
2. Create a Content Template for that content-type
3. When editing the Content Template, click on Fields and Views and insert the Map field from under the Toolset Maps section.
4. Add a Marker field and select the data-source as the custom field that you’ve added in step (1).

#1278219

My issue is resolved now. Thank you!