Add Custom Placeholder to map balloon text
-
I’ve created a location custom placeholder for a taxonomy created with ACF and have successfully added this to the single_location_format.php template. I am trying to add the same to the global map balloon. Unfortunately the fallback message ‘No Location Type’ is displayed in the balloon. When I replace the $post->ID in get_the_terms( get_the_ID($post->ID), $taxonomy ) with an actual location post id, the taxonomy for that location is displayed in all locations.
I must be missing something. How can I get the correct post id for the expanded location in the balloon?
The function is as below:
add_filter('em_location_output_placeholder','my_em_placeholder_locationtype',1,3);
function my_em_placeholder_locationtype($replace, $EM_Location, $result){
if ( $result == '#_LOCATIONTYPE' ) {
$taxonomy = 'location-type';
$replace = 'No Location Type';
$terms = get_the_terms( get_the_ID($post->ID), $taxonomy );
if ( $terms && ! is_wp_error( $terms ) ) :
$replace = join(', ', wp_list_pluck($terms, 'name'));
endif;
}
return $replace;
}
- You must be logged in to reply to this topic.