{"id":2645,"date":"2026-10-20T08:35:23","date_gmt":"2026-10-20T07:35:23","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/show-distance-and-sort-by-distance\/"},"modified":"2026-10-20T08:40:20","modified_gmt":"2026-10-20T07:40:20","slug":"show-distance-and-sort-by-distance","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/core-features\/show-distance-and-sort-by-distance\/","title":{"rendered":"How to show the distance to each listing and sort by distance"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">GeoDirectory shows a distance on a listing when it has a point to measure from. That point comes from a near search, where the visitor typed a place in the near box or chose Near: My Location. The distance is printed by GD > Distance To Post, which is already part of the default archive item template as <code>&#091;gd_post_distance&#093;<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Where the distance appears<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Search results for a near search show the distance from the searched place to each listing.<\/li>\n\n\n\n<li>On a listing details page, GD > Distance To Post shows the distance from the listing being viewed. A GD > Listings on the details page sorted by Distance to current post (details page only) gives you a nearby listings section with distances.<\/li>\n\n\n\n<li>Archive pages without a near search have no starting point, so GD > Distance To Post shows nothing there.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Distances use the unit from GeoDirectory > Settings > General > Search > Search distances (miles or km).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sorting by distance<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When a near search is active and the visitor hasn&#8217;t picked a sort order, results are sorted nearest first.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With the Advanced Search add-on, the Distance search field has a Show distance sorting option. It adds Nearest and Farthest to the sort options, with labels you choose. See the <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/advanced-search\/advanced-search-setup-guide\/\">Advanced Search setup guide<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Custom archive item templates<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you&#8217;ve built your own archive item template, add GD > Distance To Post to it where you want the distance. Its options are in <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/core-widgets\/gd-distance-to-post\/\">GD > Distance To Post<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GeoDirectory shows a distance on a listing when it has a point to measure from. That point comes from a near search, where the visitor typed a place in the near box or chose Near: My Location. The distance is printed by GD > Distance To Post, which is already part of the default archive [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[421,213],"class_list":["post-2645","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-core-features","gd_placecategory-extensions-features"],"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2645","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=2645"}],"version-history":[{"count":1,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2645\/revisions"}],"predecessor-version":[{"id":2802,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2645\/revisions\/2802"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=2645"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=2645"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=2645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}