Skip Navigation

[Resolved] Display address field as a map in a php template

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

Problem:

The issue here is that the customer wanted to use PHP to display the map and address of a location.

Solution:

The is possible by using the shortcode wrapper function in php "do_shortcode()". The function allows you to use shortcodes in your php template.

So you simply need to do a setup like this in your page template.


echo do_shortcode ('[wpv-map-render map_id="map-1"]');
echo do_shortcode ('[wpv-map-marker map_id="map-1" marker_id="marker-1" marker_field="wpcf-address"][/wpv-map-marker]');

This support ticket is created 8 years 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 0.27 hours from now. Thank you for your understanding.

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

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 4 replies, has 2 voices.

Last updated by GeorgeM4735 8 years ago.

Assisted by: Shane.

Author
Posts
#391100

I want to display a custom address field as a map in a php template. I use

echo types_render_field("address");

inside my template but I only get the address in text format. How could I display it as a map?

#391146

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi George,

Thank you for contacting our support forum.

Unfortunately not 🙁 as this field is a custom field meant specifically to work with our Toolset Maps plugin along with our Views plugin.

We do not have an API for allowing the maps to be generated using PHP so you will need to use our Views plugin along with Toolset Maps in order for you to generate the map.

Also this can only be done through the use of our interface.

Thanks,
Shane

#391188

Shane. I just entered

echo do_shortcode ('[wpv-map-render map_id="map-1"]');
echo do_shortcode ('[wpv-map-marker map_id="map-1" marker_id="marker-1" marker_field="wpcf-address"][/wpv-map-marker]');

inside my php template and the map for each post just magically appeared!

Can you explain that please?

#391367

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi George,

I initially thought you did not have our Toolset Maps or Views plugin installed. The reason is that customers are no longer able to provide us with debug information.

However when you put it like that it is actually possible by just echoing the shortcodes in the php templates.

Thanks for sharing this insight 🙂

#391370

Ok I see, thanks!

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