Nearby Locations Shortcode

This page describes the usage and attributes of the Nearby Locations shortcode. You can use this shortcode to display a list of locations nearby a specific point.

basic shortcode usage:

[gmw_nearby_locations]

Below you can learn about the different attributes that you can use with the Nearby Locations shortcode to modify its features:

Nearby Locations Global Shortcode Attributes

You can use the global shortcode attributes with any of the available "items". Here you can see the list of attributes that can be used specifically with the item "posts".

  • element_id

    Description: The element ID is a unique ID that applys to the Nearby locations shortcode. The element ID is useful when you want to apply custom styling to a specific shortcode or make a use of the hooks provided by it. The element ID will help you distinguish between the different Nearby Locations shortcodes.
    Usage: Use any numeric characters. Otherwise, the plugin will generate a random numeric value for you made up of 3 digits. Make sure you do not use the same element ID with more than one shortcode. As well make sure that the element ID that you choose is not being used by GEO my WP forms or other GEO my WP shortcodes/widgets.
    Dedfault value: random number made of 3 digits.
    Example:

    [gmw_nearby_locations element_id="18"]
  • item_type

    Description: The type of locations that you would like to display. Nearby Locations plugin provides two type ( additional types might be available with additional add-ons ):

    • posts - display post types.
    • members - display BuddyPress members.

    Usage: Enter the item type that you would like to display.
    Dedfault value: posts.
    Examples:

    [gmw_nearby_locations item_type="posts"]
  • nearby

    Description: the point which you want to display locations near to. There are 4 options for your to choose from:

    • user: display locations near the user's current location. Note that the user's current location must be set via the "Current Location" shortcode/widget.
    • item: display locations near the item that is being displayed when viewing a single template file. For example, when viewing a specific post ( in a single post page ) then the shortcode will display locations near that post.
    • item ID ( numeric value) - display locations near specific item by entering its item ID. For example, if the item_type is set to "posts" than you can enter a post ID to display locations near that post.
    • coordinates: display locations near specific coordinates by entering the latitude,longiture. For example 40.7127837,-74.005941.

    Usage: Enter "User", "item", item ID ( numeric value ) or set of coordinates comma separated ( latitude,longitude ).
    Dedfault value: user.
    Example:
    Display posts near the user's current position:

    [gmw_nearby_locations item_type="posts" nearby="user"]

    Display posts near post when viewing it in a single post page:

    [gmw_nearby_locations item_type="posts" nearby="item"]

    Display posts nearby post with ID 18:

    [gmw_nearby_locations item_type="posts" nearby="18"]

    Display locations nearby specific coordinates:

    [gmw_nearby_locations item_type="posts" nearby="40.7127837,-74.005941"]
  • units

    Description: the distance units that you would like to use.
    Usage: Enter "miles" or "kilometers".
    Dedfault value: miles.
    Example: display posts nearby the user's current location showing the distance in miles:

    [gmw_nearby_locations item_type="posts" nearby="user" units="miles"]
  • radius

    Description: the radius to search for locations.
    Usage: enter a numeric value ( ex 200 ) to be used as the radius.
    Dedfault value: 200.
    Example: Display posts within 300 miles from the user's current position:

    [gmw_nearby_locations item_type="posts" nearby="user" units="miles" radius="300"]
  • results_count

    Description: the maximum number of locations to display.
    Usage: enter a numeric value.
    Dedfault value: 5.
    Example: display maximum of 8 posts within 250 kilometers from post with ID 18:

    [gmw_nearby_locations item_type="posts" nearby="18" units="kilometers" radius="250" results_count="8"]
  • orderby

    Description: the order which you would like to display the list of locations.
    Usage: enter the orderby value you would like to use. In addition to "distance" you can also order posts by any of the orderby items listed here.
    Dedfault value: distance.
    Example: display posts ordered by the post title:

    [gmw_nearby_locations item_type="posts" orderby="title"]

    display posts ordered by the distance:

    [gmw_nearby_locations item_type="posts" orderby="distance"]
  • order

    Description: choose between ascending or descending to order the list of locations.
    Usage: enter ASC for ascending or DESC for descending.
    Dedfault value: ASC.
    Example: display posts ordered by the post title in descending order:

    [gmw_nearby_locations item_type="posts" orderby="title" order="DESC"]
  • show_map

    Description: Show locations on Google map.
    Usage: enter true/1/yes to display the map.
    Dedfault value: true.
    Example: Display posts within 150 kilometers from the post with ID 24 showing results on Google map:

    [gmw_nearby_locations item_type="posts" nearby="24" units="kilometers" radius="150" show_map="true"]
  • map_height

    Description: The map's height.
    Usage: Set the map height ( numeric value ) in pixels or percentage ( ex. 250px or 100% ).
    Dedfault value: 250px.
    Example: Display posts showing Google map with the map height set to 400px:

    [gmw_nearby_locations item_type="posts" show_map="true" map_width="400px"]
  • map_width

    Description: The map's width.
    Usage: Set the map width ( numeric value ) in pixels or percentage ( ex. 250px or 100% ).
    Dedfault value: 100%.
    Example: Display posts showing Google map with the map height set to 350px and map width set to 300px:

    [gmw_nearby_locations item_type="posts" show_map="true" map_height="350px" map_width="300px"]
  • map_type

    Description: Choose the map type.
    Usage: Set the map type between: ROADMAP, SATELLITE, HYBRID, TERRAIN.
    Dedfault value: ROADMAP
    Example: Display posts showing Google map with the map height set to 350px and map width set to 300px and the map type set to TERRAIN:

    [gmw_nearby_locations item_type="posts" show_map="true" map_height="350px" map_width="300px" map_type="TERRAIN"]
  • show_locations_list

    Description: Show/hide the list of locations.
    Usage: set to true/1/yes if you'd like to show the list of locations.
    Dedfault value: true
    Example: Display posts showing the list of locations and Google map:

    [gmw_nearby_locations item_type="posts" show_locations_list="true" show_map="true"]

    Example: Display posts showing Google map but without the list of locations:

    [gmw_nearby_locations item_type="posts" show_locations_list="false" show_map="true"]
  • group_markers

    Description: Group nearby map markers using markers clusters.
    Usage: use markers_clusterer if you'd like to group markers. Otherwise, set to false.
    Dedfault value: markers_clusterer
    Example: Display posts showing Google and grouping nearby markers:

    [gmw_nearby_locations item_type="posts" show_map="true" group_markers="markers_clusterer]
  • show_image

    Description: Display the item's image. Image can be the featured image of a post or the avatar of BuddyPress member.
    Usage: enter true/1/yes to show the item's image.
    Default value: true
    Example:

    [gmw_nearby_locations show_image="true"]
  • show_distance

    Description: display the distance for each location in the list of results.
    Usage: use true/1/yes to show the distance.
    Default value: true
    Example:

    [gmw_nearby_locations show_distance="true"]
  • address_fields

    Description: The address fields that you would like to display.
    Usage: Enter any of the address fields that you would like to display comma separated. You can choose a single or multiple address fields. The fields available are street, apt, city, state, zipcode, county and address ( for full address ). Otherwise, enter 0 to hide the address.
    default value: address ( full address ).
    Example: display the city and state of each location in the list of results:

    [gmw_nearby_locations address_fields="city,country"]
  • show_random

    Description: display random locations if no locations were found nearby.
    Usage: true/1/yes to display random locations.
    Default value: true
    Example: search for posts within 200 miles from the user's current position. If nothing was found display random locations:

    [gmw_nearby_locations item_type="posts" nearby="user" units="miles" radius="200" show_random="true"]
  • get_directions

    Description: Display "get Directions" link in each location in the list of results. The link will open a new page with Google map showing the directions to the location.
    Usage: enter any text that you would like to use as the "get directions" label or set to 0 if you wish to hide the get directions link.
    Default Value: Get directions.
    Example:

    [gmw_nearby_locations get_directions="Get directions"]
  • results_template

    Description: Choose the results template file. The plugin provide different results tempalte files out of the box. You can as well modify or create your own results template files.
    Usage: enter the folder's name of the results template file that you would like to use. Currently there are 3 template fiels availabe: default, lightcoral and lightseagreen.
    Default Value: lightcoral
    Example:

    [gmw_nearby_locations results_template="lightseagreen"]
  • no_results_message

    Description: Message that will display if no locations were found ( and random locations is set to false ).
    Usage: enter any text that you would like to use as the "No results" message. Otherwise, set to 0 if you wish to hide the message.
    Default Value: Nothing was found near you.
    Example:

    [gmw_nearby_locations show_random="false" no_results_message="No locations were found"]

Nearby Posts Shortcode Attributes

The shortcode attributes that you can only use with the item "posts".

  • post_types

    Description: The post types that you would like to display.
    Usage: enter a single or multiple post types comma separated.
    Dedfault value: post
    Example: Display locations of post types post and job_listing

    [gmw_nearby_locations item_type="posts" post_types="post,job_listing"]
  • include_terms

    Description: filter posts by including taxonomy term IDs
    Usage: enter term IDs of any existing taxonomy comma sepatrated. otherwise, do not use this attribute.
    Dedfault value: none.
    Example: Display locations ( posts ) of post type post that have the termd IDs 12 or 22

    [gmw_nearby_locations item_type="posts" post_types="post" include_terms="12,22"]
  • exclude_terms

    Description: filter posts by excluding taxonomy term IDs
    Usage: enter term IDs of any existing taxonomy comma sepatrated. otherwise, do not use this attribute.
    Dedfault value: none.
    Example: Display locations ( posts ) of post type post that do not have the termd IDs 10 or 3

    [gmw_nearby_locations item_type="posts" post_types="post" exclude_terms="10,3"]