Select Page

When a View is listing posts, users, or taxonomy terms that have an Address field type, you can order the output by distance.

Edit a View and scroll down to the Ordering section. There, select to order by a custom field of an Address type. In the third drop-down, select the As a distance from option.

Fourth drop-down allows you to select if the distance is from a fixed location or the current user’s geolocation.

Selecting the Fixed option will make a fifth option field to appear. It’s an autocomplete field so just start typing the name of the wanted location.

Ordering View by a distance from a fixed location
Ordering View by a distance from a fixed location

If you select the Visitor Location option, you have to wrap your View in a wpv-geolocation shortcode. For example, if you inserted your View in a page, it would look something like this:

[wpv-geolocation] [wpv-view name=”views-1472″] [/wpv-geolocation]