Skip Navigation

[Resolved] How to create a Google Maps marker with custom fields and a custom post type

This support ticket is created 5 years, 8 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
- 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/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by roulartaM 5 years, 8 months ago.

Assisted by: Waqar.

Author
Posts
#1230877

Tell us what you are trying to do?
I've installed the Toolset Maps plugin and now I want to create a maps marker in my loop with a collection of this data:

- a custom field called 'street' (from custom post type 'shops')
- a custom field called 'housenumber' (from custom post type 'shops')
- the wp-title field (from the related custom post type called 'cities')
- a custom field called 'zipcode' linked to the custom post type called 'cities'.

This is the relationship between my 2 custop post types:
Cities [0 .. 1] << Shops [*]

How can I combine those 4 fields so I can output it in the 'Marker' shortcode?

Thanks for helping!

#1230985

Hi Roularta,

Thank you for waiting.

The "wpv-map-marker" shortcode, supports an "address" attribute, which can be used to pass on the location's information.
( ref: https://toolset.com/documentation/user-guides/maps-shortcodes/#wpv-map-marker )

Google's Location API seems to understand the address information in this order/format:


House Number, Street Direction, Street Name, Street Suffix, City, State, Zip, Country

Based on that, you can use the available data in the marker shortcode like this:
( assuming it is being used in the "Shops" post loop in a View )


[wpv-map-marker map_id='map-1' marker_id='marker-[wpv-post-id]' address='[types field="shop-housenumber"][/types], [types field="shop-street"][/types], [wpv-post-title item="@city-shop.parent"], [types field="city-zipcode" item="@city-shop.parent"][/types]'][/wpv-map-marker]

Feel free to replace the field slugs and map_id with the actual data on your website.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1232274

That code does the trick! I'm glad I didn't need to change my database by adding an extra custom field to make it work. Thanks! 🙂