Skip Navigation

[Gelöst] Defining marker address with 2 custom fields

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 13:00 8:00 – 13:00 8:00 – 13:00 8:00 – 13:00 8:00 – 13:00 -
- 14:00 – 17:00 14:00 – 17:00 14:00 – 17:00 14:00 – 17:00 14:00 – 17:00 -

Supporter timezone: Indian/Mauritius (GMT+04:00)

This topic contains 2 Antworten, has 2 Stimmen.

Last updated by Pat vor 7 Jahre.

Assisted by: Arvish Mungur.

Author
Artikel
#513225

Pat

Hello,

I have a map + markers inserted in a Views. I have 2 custom fields (town) (region) and would like to use the combination of these 2 custom field (town + region) to define the address for the marker.

The reason for this is that town is sometimes not sufficient to define the right location.

Is there a way to do this?
Regards
Pat

#513394

Hi Pat,

Thank you for contacting Toolset Support.

I will be happy to help you with your issue.

I would suggest creating an ‘address’ custom field to contain the combined or full address that you would want to pass to the map marker.

You can achieve this by combining the other custom fields and saving it to one ‘address’ custom field using the 'save_post' hook.
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post

Example:

function save_map_marker_address() {

$post_id = get_the_ID();

$town = get_post_meta( $post_id, 'town', true );
$region = get_post_meta( $post_id, 'region', true );

$address = $town.','.$region;

update_post_meta( $post_id, 'address', $address );

}
add_action( 'save_post', 'save_map_marker_address' );

To add the map marker, in the marker settings window, select “Another custom field” for the “Marker address comes from” section, use “$parent” as the Post ID and enter the custom field key.

E.g
#hidden link

Please let me know if this fixes it.

Kind regards

#513576

Pat

Hi Arvish,

Many thanks for your support.
Regards
Pat

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