Skip Navigation

[Resolved] Google Map marker from parent post field

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

Problem: On a child post, I would like to display a map marker using an address field on its parent post. How should I update my map marker shortcode to point at the parent post type?

Solution: Use the "id" attribute and the "$slug" operator to point to the parent post from a child post.

[wpv-map-marker map_id="store-map" marker_id="store-address"
marker_field="wpcf-address" id="$store"][/wpv-map-marker]

Relevant Documentation: https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/

This support ticket is created 7 years, 2 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 3 replies, has 2 voices.

Last updated by Scott Roberts 7 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#561640

I am trying to: display a marker on Google map in a child post type using a field from the parent post.

This part of the instruction is unclear to me:
-----
To define a custom source, you can also set a specific post, user or term ID using the id parameter of the wpv-map-marker shortcode.

In case of post fields, you can also use the following placeholders:

$parent for the native parent post
$post_type_slug for the Types parent post

When the marker from a term field is outside a View listing terms, term ID field is mandatory in order to display a valid marker.
----

This is the marker code at the moment:

[wpv-map-render map_id="store-map"]
[wpv-map-marker map_id="store-map" marker_id="store-address" 
marker_field="wpcf-address"][/wpv-map-marker]

wpcf-address is the field in the parent post. I've retrieved the title of the parent using

[wpv-post-title id="$store"]

, but I don't understand the proper syntax for the map marker.

#561641

I've pushed the site to staging. You can see the page result at hidden link

#561744

Hi, you will add the "id" attribute to the map marker shortcode, and use the "$store" operator to access the field in the store post type.

[wpv-map-marker map_id="store-map" marker_id="store-address"
marker_field="wpcf-address" id="$store"][/wpv-map-marker]

Is this map designed to only ever show one result at a time? If so, the marker_id attribute looks okay. If the map will contain multiple markers, the marker_id attribute should be unique for each result. You can add the post ID like this if the map contains more than one marker:

[wpv-map-marker map_id="store-map" marker_id="store-address-[wpv-post-id]"
marker_field="wpcf-address" id="$store"][/wpv-map-marker]
#561766

Christian, thank you for the help. It's working as intended now.