Black Friday & Cyber Monday
50% OFF All plans, upgrades & renewals
View offers

EXTENSIONS

Display Nearby Locations with a shortcode or widget

Display nearby GEO my WP posts with shortcode examples, origin choices, map and list attributes, widget setup and fallback troubleshooting.

4 min read · Updated December 1, 2026

Nearby Locations displays geotagged posts around a visitor, a saved post location or fixed coordinates. It supplies the [gmw_nearby_locations] shortcode, the [gmw_nearby_posts] alias and the GEO my WP Nearby Posts widget.

Prepare the records

Install GEO my WP and Nearby Locations, enable Posts Locator, and save valid locations on the posts you want to show. The shipped implementation is for posts; it does not supply nearby BuddyPress members, users or groups. Select any page/custom post types explicitly when they should be searched.

Add a first shortcode

[gmw_nearby_locations object_type="post" nearby="40.7128,-74.0060" post_types="post" radius="25" units="metric" results_count="5" show_random_locations="0"]

This example searches geotagged posts within 25 kilometers of the supplied New York coordinates and requests up to five results. Replace the point and post types with your own. Disabling random-location fallback keeps an empty nearby search from being replaced by broader results.

Paste the shortcode into a supported Shortcode block, shortcode element or content area. Open the frontend and check the actual output before refining the options.

Choose an origin with nearby

  • nearby="user" uses the visitor coordinates available to GEO my WP.
  • nearby="object" uses the current post/page's saved location on a single post or page view.
  • nearby="123" uses post 123's saved location. Replace the example ID.
  • nearby="latitude,longitude" supplies fixed coordinates.

A post-based origin must have a saved location. Visitor mode does not itself guarantee that the visitor has been located. Check the site's location detection and the behavior when coordinates are absent.

Search and result attributes

  • object_type: use post for the shipped implementation. object is a compatibility alias.
  • post_types: comma-separated post type slugs; default post.
  • radius: numeric search radius; default 200.
  • units: metric for kilometers or imperial/miles for miles; default metric.
  • results_count: maximum results requested; default 5.
  • orderby and order: result ordering; defaults distance and ascending.
  • include_taxonomies, exclude_taxonomies, include_terms, exclude_terms and taxonomies_relation: supported predefined taxonomy/term restrictions. Use current attributes rather than the deprecated include_tax, exclude_tax or tax_relation names.
  • show_random_locations: allow fallback results when no nearby results are found; default enabled. Use 0 when only nearby matches should appear.
  • no_results_message: text displayed when no results are available.

Map and list presentation

  • show_map and show_locations_list: independently enable the map and list. Both default to enabled; do not disable both.
  • map_width and map_height: map dimensions; defaults 100% and 250px.
  • zoom_level and map_type: map zoom/type; defaults auto and ROADMAP. Provider support differs.
  • map_icon_url, map_icon_size, user_map_icon_url and user_map_icon_size: result and visitor marker appearance. Size values are width/height pairs such as 25,41.
  • results_template: results template, default responsive-1. custom_template selects an installed custom template.
  • results_view: default result presentation, initially grid.
  • show_image, image_width, image_height and no_image_url: featured-image output and fallback. Defaults include enabled images, width 120px and automatic height.
  • show_distance and address_fields: distance/address output; defaults enabled distance and address.
  • show_taxonomies: taxonomy details in the posts result presentation, enabled by default.
  • post_excerpt: content or excerpt for an excerpt source, otherwise disabled. excerpt_word_count defaults to 20; excerpt_link controls its link text.
  • widget_title: an optional title for this element.
  • disable_core_styles: disable the element's core styles when a custom presentation supplies them.
  • element_id: a positive identifier for the element. Supply distinct IDs when placing several elements on one page.

Boolean attributes accept values such as 1/0, true/false and yes/no. Keep advanced template/provider-specific options tied to a tested presentation. The extension's underlying argument list also contains integration hooks/options; their presence alone does not prove a visible feature works in every template.

Use the widget

Add GEO my WP Nearby Posts in a supported WordPress widget area. Choose its post types and nearby origin, then configure the offered search/output controls. The widget additionally exposes its supported term inclusion/exclusion and order-by settings. Save the widget and check the frontend of the page containing that widget area.

Understand fallback results

When nearby results are empty and show_random_locations is enabled, the extension can run a fallback query after removing the radius. That output is not proof that the records meet the original nearby distance. This also matters when visitor mode has no coordinates. Disable fallback for a strict nearby display and choose an honest empty-state message.

Check missing or incorrect output

  1. Confirm Nearby Locations and Posts Locator are active.
  2. Check the searched post type and the saved locations.
  3. Test a fixed coordinate origin to separate location-detection issues from result querying.
  4. Check radius and units together.
  5. Confirm at least the list or map is enabled.
  6. If unrelated listings appear, check random-location fallback.
  7. If a custom template is selected, confirm that its files exist and suit the installed version.