{"id":2925,"date":"2026-10-20T08:39:20","date_gmt":"2026-10-20T07:39:20","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/change-address-format-listings-map-bubble-2\/"},"modified":"2026-10-20T08:39:20","modified_gmt":"2026-10-20T07:39:20","slug":"change-address-format-listings-map-bubble-2","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/code-snippets\/change-address-format-listings-map-bubble-2\/","title":{"rendered":"How to change the address format on listings and the map bubble"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">GeoDirectory shows the address in two ways. The <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/core-widgets\/gd-post-address\/\">GD &gt; Post Address<\/a> block has its own Address template setting. Where the address appears as an output location of the Address field (the details page sidebar, the listings page and the map bubble), GeoDirectory uses a default template that puts each part on a new line. You can replace that default with a filter, or use the block in those places.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Address template tags<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Templates are built from these tags: <code>%%street%%<\/code>, <code>%%neighbourhood%%<\/code>, <code>%%city%%<\/code>, <code>%%region%%<\/code>, <code>%%country%%<\/code>, <code>%%zip%%<\/code>, <code>%%latitude%%<\/code>, <code>%%longitude%%<\/code>, <code>%%post_title%%<\/code> and <code>%%br%%<\/code>. Adding <code>_br<\/code> to a tag puts a line break after it, and <code>_brc<\/code> a comma and a line break. For example, <code>%%street_br%% %%city%%, %%region%% %%zip%%<\/code> gives the street on one line and &#8220;City, Region Zip&#8221; on the next.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Option 1: change the default template with a filter<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>geodir_cf_address_template<\/code> filter changes the template for the Address field outputs. Its third argument is the output location, so you can limit it to the places you want:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">add_filter( &#039;geodir_cf_address_template&#039;, &#039;my_gd_address_template&#039;, 10, 3 );\nfunction my_gd_address_template( $template, $cf, $location ) {\n\tif ( in_array( $location, array( &#039;detail&#039;, &#039;listing&#039;, &#039;mapbubble&#039; ), true ) ) {\n\t\t$template = &#039;%%street_br%% %%city%%, %%region%% %%zip%%&#039;;\n\t}\n\n\treturn $template;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">GD &gt; Post Address blocks pass <code>none<\/code> as their location, so this snippet leaves their own templates alone. Add it with the <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/useful-plugins\/code-snippets-plugin\/\">Code Snippets plugin<\/a> or your child theme&#8217;s functions.php.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Option 2: use GD &gt; Post Address in your templates<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Add GD &gt; Post Address with your template to the archive item template, and to the Details page template or sidebar.<\/li>\n\n\n\n<li>In Places &gt; Settings &gt; Custom Fields, edit the Address field and untick the matching places in &#8220;Show in extra output location&#8221; (Details page sidebar, Listings page), so the address doesn&#8217;t appear twice.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">The map bubble is a PHP template (map-popup.php) rather than a page. Option 1 covers its address, and if you want to change the whole bubble you can copy the template into your theme as explained in <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/how-tos\/customizing-templates\/\">Customizing templates<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GeoDirectory shows the address in two ways. The GD &gt; Post Address block has its own Address template setting. Where the address appears as an output location of the Address field (the details page sidebar, the listings page and the map bubble), GeoDirectory uses a default template that puts each part on a new line. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[211,433],"class_list":["post-2925","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-tips-tricks-more","gd_placecategory-code-snippets"],"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2925","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/types\/gd_place"}],"author":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/comments?post=2925"}],"version-history":[{"count":0,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2925\/revisions"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=2925"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=2925"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=2925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}