Title: WP Geo search
Author: jhackett1
Published: <strong>2020년 12월 13일</strong>
Last modified: 2021년 9월 6일

---

플러그인 검색

![](https://ps.w.org/wp-geo-search/assets/banner-772x250.jpg?rev=2438555)

이 플러그인은 **최근 3개의 주요 워드프레스 출시와 시험 되지 않았습니다**. 워드프레스의
좀 더 최근 버전으로 이용할 때 더 이상 관리되지 않고 지원되지 않고 호환성 문제가 
있을 수 있습니다.

![](https://ps.w.org/wp-geo-search/assets/icon-256x256.png?rev=2438555)

# WP Geo search

 작성자: [jhackett1](https://profiles.wordpress.org/jhackett1/)

[다운로드](https://downloads.wordpress.org/plugin/wp-geo-search.zip)

 * [세부사항](https://ko.wordpress.org/plugins/wp-geo-search/#description)
 * [평가](https://ko.wordpress.org/plugins/wp-geo-search/#reviews)
 * [개발](https://ko.wordpress.org/plugins/wp-geo-search/#developers)

 [지원](https://wordpress.org/support/plugin/wp-geo-search/)

## 설명

A plugin to add location-aware geographical search to [WP_Query](https://developer.wordpress.org/reference/classes/wp_query/).

You can use it to power location-aware apps, such as showing a user results near
them.

### 🔎 Using it in a query

Adding a `geo_query` parameter to WP_Query will add a “distance” column to the returned
results, provided they have the right metadata.

You can then display this in your templates.

You can use a location search parameter, which will be [geocoded](https://ko.wordpress.org/plugins/wp-geo-search/?output_format=md#geocoding)
or directly provide latitude and longitude values:

    ```
    $query = new WP_Query(array(
        "geo_query" => array(
                "location" => "London"
        )
    ))

    $query = new WP_Query(array(
        "geo_query" => array(
                "latitude" => -52.005,
                "longitude" => 0.005,
        )
    ))
    ```

Optionally, you can then filter by search radius.

By default, distances are given in miles. You can provide `"units" => "km"` if you
need kilometres.

    ```
    $query = new WP_Query(array(
        "geo_query" => array(
                "latitude" => -52.005,
                "longitude" => 0.005,
                "radius" => 10
        )
    ))
    ```

Or order by nearness:

    ```
    $query = new WP_Query(array(
        "geo_query" => array(
                "latitude" => -52.005,
                "longitude" => 0.005
        ),
        "orderby" => "geo"
    ))
    ```

### Displaying distance in templates

In a `WP_Query` loop that includes a `geo_query`, you can use two extra functions
to show distance away:

 * `jhgs_get_the_distance(object $post)` – which returns a rounded integer for the
   distance away, similar to `get_the_title()`
 * `jhgs_the_distance(string $less_than_one, string $one, string $more_than_one)`–
   which displays an approximate human-readable string, similar to `the_title()`
 * jhgs_the_distance will show one of three messages depending on whether the rounded
   distance is less than one, one, or greater than one. By default these are:
 * “Less than a mile away”
 * “About a mile away”
 * “About %s miles away”

If you need to use different units or translations, can pass three [printf-formatted](https://www.php.net/manual/en/function.printf.php)
strings to `jhgs_the_distance()` to override these messages. Put `%s` where you 
want the value.

If you need the _exact_, unrounded value, you can use `$post->distance`.

### Geocoding

[Nominatim](https://nominatim.org/)‘s service is used for geocoding location searches.

Using it is subject to an [acceptable use policy](https://operations.osmfoundation.org/policies/nominatim/)–
if you use case will involve lots of API calls, you should replace it with a paid
alternative, like [Google](https://developers.google.com/maps/documentation/geocoding/overview)‘
s.

### 📍 Populating latitude and longitude data

It looks for two [custom field](https://wordpress.org/support/article/custom-fields/)
values with the keys `latitude` and `longitude` on your posts.

It’s agnostic about how you supply this data. The simplest thing to do is type it
in using WordPress’s built-in custom field editor.

You could also hook into the `save_post` action to populate meta whenever you create
or change a post, by adding a snippet like this to your theme’s `functions.php`:

    ```
    function example_update_latlngs($post){
        $location = get_field("location", $post);
        if(isset($location)){
            update_post_meta($post, "longitude", $location["lng"]);
            update_post_meta($post, "latitude", $location["lat"]);
        }
    }

    add_action("save_post", "example_update_latlngs", 10, 3);
    ```

This example assumes you are using an [ACF Google Map](https://www.advancedcustomfields.com/resources/google-map/)
field called “location”, but the data could come from anywhere, including a custom
meta box you code yourself, so long as the post meta keys are right.

### Bulk-updating existing posts

If you have many posts that you need to add longitude and latitude meta to in bulk,
you could add something like this to `functions.php`, which will run on [theme activation](https://developer.wordpress.org/reference/hooks/after_switch_theme/):

    ```
    function example_update_all_latlngs(){
        $query = new WP_Query(array(
            "posts_per_page" => -1
        ));
        foreach($query->get_posts() as $post){
            // Function from above
            example_update_latlngs($post);
        }
    }

    add_action('after_switch_theme', 'example_update_all_latlngs');
    ```

## FAQ

### I’ve activated it, but I can’t see any changes to my website

This plugin adds extra functionality to `WP_Query` – it’s up to you to make use 
of that functionality in your theme.

## 후기

![](https://secure.gravatar.com/avatar/5a03b25b8dfba3cb9534acc51827a2d2424ce46deaac7f3187bca66b5ddcf7b2?
s=60&d=retro&r=g)

### 󠀁[Awesome function!](https://wordpress.org/support/topic/awesome-function/)󠁿

 [rogiervanroon](https://profiles.wordpress.org/rogiervanroon/) 2022년 6월 3일

This is truly an awesome function for WP developers! Simple and effective.

![](https://secure.gravatar.com/avatar/b0c408e23888876dc9c310a5fa562bd0810f4949bd11c37ea999604dc660849f?
s=60&d=retro&r=g)

### 󠀁[Amazing perfection.](https://wordpress.org/support/topic/amazing-perfection-2/)󠁿

 [kamihicouki](https://profiles.wordpress.org/kamihicouki/) 2021년 4월 6일

The definitive neighborhood search plugin that easily extends WP_Query for everyone
to understand, and is fully functional. I am so happy to have found this plugin.

 [ 모든 2 평가 읽기 ](https://wordpress.org/support/plugin/wp-geo-search/reviews/)

## 기여자 & 개발자

“WP Geo search”(은)는 오픈 소스 소프트웨어입니다. 다음의 사람들이 이 플러그인에 
기여하였습니다.

기여자

 *   [ jhackett1 ](https://profiles.wordpress.org/jhackett1/)

[자국어로 “WP Geo search”(을)를 번역하세요.](https://translate.wordpress.org/projects/wp-plugins/wp-geo-search)

### 개발에 관심이 있으십니까?

[코드 탐색하기](https://plugins.trac.wordpress.org/browser/wp-geo-search/)는, [SVN 저장소](https://plugins.svn.wordpress.org/wp-geo-search/)
를 확인하시거나, [개발 기록](https://plugins.trac.wordpress.org/log/wp-geo-search/)
을 [RSS](https://plugins.trac.wordpress.org/log/wp-geo-search/?limit=100&mode=stop_on_copy&format=rss)
로 구독하세요.

## 변경이력

#### 0.1

 * First release

## 기초

 *  버전 **0.1**
 *  최근 업데이트: **5년 전**
 *  활성화된 설치 **70+**
 *  워드프레스 버전 ** 4.0 또는 그 이상 **
 *  다음까지 시험됨: **5.8.0**
 *  PHP 버전 ** 7.0 또는 그 이상 **
 *  언어
 * [English (US)](https://wordpress.org/plugins/wp-geo-search/)
 * 태그:
 * [distance](https://ko.wordpress.org/plugins/tags/distance/)[geo](https://ko.wordpress.org/plugins/tags/geo/)
   [location](https://ko.wordpress.org/plugins/tags/location/)[nominatim](https://ko.wordpress.org/plugins/tags/nominatim/)
 *  [고급 보기](https://ko.wordpress.org/plugins/wp-geo-search/advanced/)

## 평점

 별 5점 만점에 5점.

 *  [  2/5-별점 후기     ](https://wordpress.org/support/plugin/wp-geo-search/reviews/?filter=5)
 *  [  0/4-별점 후기     ](https://wordpress.org/support/plugin/wp-geo-search/reviews/?filter=4)
 *  [  0/3-별점 후기     ](https://wordpress.org/support/plugin/wp-geo-search/reviews/?filter=3)
 *  [  0/2-별점 후기     ](https://wordpress.org/support/plugin/wp-geo-search/reviews/?filter=2)
 *  [  0/1-별점 후기     ](https://wordpress.org/support/plugin/wp-geo-search/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/wp-geo-search/reviews/#new-post)

[모든  리뷰 보기](https://wordpress.org/support/plugin/wp-geo-search/reviews/)

## 기여자

 *   [ jhackett1 ](https://profiles.wordpress.org/jhackett1/)

## 지원

할 말 있으신가요? 도움이 필요하신가요?

 [지원 포럼 보기](https://wordpress.org/support/plugin/wp-geo-search/)

## 기부

이 플러그인이 발전하도록 도우시겠습니까?

 [ 이 플러그인에 기부하기 ](https://github.com/jhackett1/wp-geo-search)