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: usepostfor the shipped implementation.objectis a compatibility alias.post_types: comma-separated post type slugs; defaultpost.radius: numeric search radius; default 200.units:metricfor kilometers orimperial/milesfor miles; default metric.results_count: maximum results requested; default 5.orderbyandorder: result ordering; defaults distance and ascending.include_taxonomies,exclude_taxonomies,include_terms,exclude_termsandtaxonomies_relation: supported predefined taxonomy/term restrictions. Use current attributes rather than the deprecatedinclude_tax,exclude_taxortax_relationnames.show_random_locations: allow fallback results when no nearby results are found; default enabled. Use0when only nearby matches should appear.no_results_message: text displayed when no results are available.
Map and list presentation
show_mapandshow_locations_list: independently enable the map and list. Both default to enabled; do not disable both.map_widthandmap_height: map dimensions; defaults100%and250px.zoom_levelandmap_type: map zoom/type; defaultsautoandROADMAP. Provider support differs.map_icon_url,map_icon_size,user_map_icon_urlanduser_map_icon_size: result and visitor marker appearance. Size values are width/height pairs such as25,41.results_template: results template, defaultresponsive-1.custom_templateselects an installed custom template.results_view: default result presentation, initiallygrid.show_image,image_width,image_heightandno_image_url: featured-image output and fallback. Defaults include enabled images, width120pxand automatic height.show_distanceandaddress_fields: distance/address output; defaults enabled distance andaddress.show_taxonomies: taxonomy details in the posts result presentation, enabled by default.post_excerpt:contentorexcerptfor an excerpt source, otherwise disabled.excerpt_word_countdefaults to 20;excerpt_linkcontrols 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
- Confirm Nearby Locations and Posts Locator are active.
- Check the searched post type and the saved locations.
- Test a fixed coordinate origin to separate location-detection issues from result querying.
- Check radius and units together.
- Confirm at least the list or map is enabled.
- If unrelated listings appear, check random-location fallback.
- If a custom template is selected, confirm that its files exist and suit the installed version.
