{"id":2307,"date":"2026-10-20T08:30:41","date_gmt":"2026-10-20T07:30:41","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/change-address-format\/"},"modified":"2026-10-20T08:59:28","modified_gmt":"2026-10-20T07:59:28","slug":"change-address-format","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/code-snippets\/change-address-format\/","title":{"rendered":"How to change the address format in GeoDirectory"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">GeoDirectory builds the listing address from a template of tags. You can change the order of the parts, leave some out (the country, for example) and choose where the line breaks go. You can do it for one block with the address template setting, or for the whole site with a filter.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The default template is:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-markup\">%%street_br%% %%street2_br%% %%neighbourhood_br%% %%city_br%% %%region_br%% %%zip_br%% %%country%%<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">How the tags work<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The parts you can use are <code>street<\/code>, <code>street2<\/code>, <code>neighbourhood<\/code>, <code>city<\/code>, <code>region<\/code>, <code>zip<\/code>, <code>country<\/code>, <code>latitude<\/code>, <code>longitude<\/code> and <code>post_title<\/code>. Wrap each in double percent signs. Add a suffix to control what follows the value:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>%%city%%<\/code> outputs the value only.<\/li>\n\n\n\n<li><code>%%city_br%%<\/code> adds a line break after it.<\/li>\n\n\n\n<li><code>%%city_c%%<\/code> adds a comma and a space.<\/li>\n\n\n\n<li><code>%%city_brc%%<\/code> adds a comma and a line break.<\/li>\n\n\n\n<li><code>%%city_space%%<\/code> adds a space.<\/li>\n\n\n\n<li><code>%%city_dash%%<\/code> adds a spaced hyphen.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The separator is only added when that part has a value, so an empty field does not leave a stray comma or blank line. To drop a part, leave its tag out.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Change it for one block<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/core-widgets\/gd-post-address\/\">GD > Post Address<\/a> block has an Address template field. Enter your template there, or use the shortcode:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-markup\">&#091;gd_post_address address_template=&quot;%%street_br%% %%city_c%% %%region_space%% %%zip%%&quot;&#093;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Change it everywhere<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To change the address format wherever GeoDirectory outputs the address field, use the <code>geodir_cf_address_template<\/code> filter. Add this with the <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/useful-plugins\/code-snippets-plugin\/\">Code Snippets plugin<\/a> or your child theme functions.php and edit the template to suit:<\/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\t\/\/ Street on one line, then city, region and zip on the next. No country.\n\treturn &#039;%%street_br%% %%city_c%% %%region_space%% %%zip%%&#039;;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The filter also receives the field settings in <code>$cf<\/code> and the output location in <code>$location<\/code>, so you can return a different template for, say, the listing page and the archive cards.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GeoDirectory builds the listing address from a template of tags. You can change the order of the parts, leave some out (the country, for example) and choose where the line breaks go. You can do it for one block with the address template setting, or for the whole site with a filter. The default template [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[211,433],"class_list":["post-2307","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\/2307","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=2307"}],"version-history":[{"count":2,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2307\/revisions"}],"predecessor-version":[{"id":2731,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2307\/revisions\/2731"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=2307"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=2307"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=2307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}