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?
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
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?
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/
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).
My issue is resolved now. Thank you!