The map bubble is the info window that opens when someone clicks a marker on a GeoDirectory map. You can change which fields it shows from the settings, and change the layout with a template in your child theme.
Choose the fields in the bubble
- Go to Places > Settings > Custom Fields.
- Click a field you want in the bubble, such as Phone or Address.
- In “Show in extra output location”, add Map bubble. Remove it from fields you don’t want there.
- Save the field.
Change the bubble layout
The bubble content comes from a template file made of GeoDirectory shortcodes: the title, an image, the rating, the favorite link and [gd_output_location location="mapbubble"] for the fields you picked above. To change it, copy the template into your child theme:
- Copy
wp-content/plugins/geodirectory/templates/bootstrap/map/map-popup.php. - Paste it into
wp-content/themes/your-child-theme/geodirectory/bootstrap/map/map-popup.php. - Edit the copy. You can remove shortcodes, move them, or add others such as
[gd_post_meta key="phone"].
Using a child theme means your changes survive theme updates. See customizing templates for more on template overrides.
Show the address on one line
By default the address puts each part on its own line. This snippet changes only the address in the map bubble so the parts are separated by commas:
add_filter( 'geodir_cf_address_template', function( $template, $cf, $location ) {
if ( $location === 'mapbubble' ) {
$template = '%%street_c%% %%city_c%% %%region_c%% %%zip_c%% %%country%%';
}
return $template;
}, 10, 3 );
In the template, _br after a part adds a line break and _c adds a comma. Add the snippet with the Code Snippets plugin or your child theme’s functions.php.
If logos look too large in the bubble, see how to fix logo size issues in map bubbles.