[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"$fAs_wP308JlfpMBW-_mH2h1L69p20mav_D4JYfYN5OPk":3},{"slug":4,"display_name":4,"profile_url":5,"plugin_count":6,"total_installs":7,"avg_security_score":8,"avg_patch_time_days":9,"trust_score":10,"computed_at":11,"plugins":12},"jhackett1","https:\u002F\u002Fprofiles.wordpress.org\u002Fjhackett1\u002F",1,70,85,30,84,"2026-05-20T06:53:58.393Z",[13],{"slug":14,"name":15,"version":16,"author":4,"author_profile":5,"description":17,"short_description":18,"active_installs":7,"downloaded":19,"rating":20,"num_ratings":21,"last_updated":22,"tested_up_to":23,"requires_at_least":24,"requires_php":25,"tags":26,"homepage":32,"download_link":33,"security_score":8,"vuln_count":34,"unpatched_count":34,"last_vuln_date":35,"fetched_at":36},"wp-geo-search","WP Geo search","0.1","\u003Cp>A plugin to add location-aware geographical search to \u003Ca href=\"https:\u002F\u002Fdeveloper.wordpress.org\u002Freference\u002Fclasses\u002Fwp_query\u002F\" rel=\"nofollow ugc\">WP_Query\u003C\u002Fa>.\u003C\u002Fp>\n\u003Cp>You can use it to power location-aware apps, such as showing a user results near them.\u003C\u002Fp>\n\u003Ch3>🔎 Using it in a query\u003C\u002Fh3>\n\u003Cp>Adding a \u003Ccode>geo_query\u003C\u002Fcode> parameter to WP_Query will add a “distance” column to the returned results, provided they have the right metadata.\u003C\u002Fp>\n\u003Cp>You can then display this in your templates.\u003C\u002Fp>\n\u003Cp>You can use a location search parameter, which will be \u003Ca href=\"#geocoding\" rel=\"nofollow ugc\">geocoded\u003C\u002Fa> or directly provide latitude and longitude values:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>$query = new WP_Query(array(\n    \"geo_query\" => array(\n            \"location\" => \"London\"\n    )\n))\n\n$query = new WP_Query(array(\n    \"geo_query\" => array(\n            \"latitude\" => -52.005,\n            \"longitude\" => 0.005,\n    )\n))\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Optionally, you can then filter by search radius.\u003C\u002Fp>\n\u003Cp>By default, distances are given in miles. You can provide \u003Ccode>\"units\" => \"km\"\u003C\u002Fcode> if you need kilometres.\u003C\u002Fp>\n\u003Cpre>\u003Ccode>$query = new WP_Query(array(\n    \"geo_query\" => array(\n            \"latitude\" => -52.005,\n            \"longitude\" => 0.005,\n            \"radius\" => 10\n    )\n))\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Or order by nearness:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>$query = new WP_Query(array(\n    \"geo_query\" => array(\n            \"latitude\" => -52.005,\n            \"longitude\" => 0.005\n    ),\n    \"orderby\" => \"geo\"\n))\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch3>Displaying distance in templates\u003C\u002Fh3>\n\u003Cp>In a \u003Ccode>WP_Query\u003C\u002Fcode> loop that includes a \u003Ccode>geo_query\u003C\u002Fcode>, you can use two extra functions to show distance away:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Ccode>jhgs_get_the_distance(object $post)\u003C\u002Fcode> – which returns a rounded integer for the distance away, similar to \u003Ccode>get_the_title()\u003C\u002Fcode>\u003C\u002Fli>\n\u003Cli>\n\u003Cp>\u003Ccode>jhgs_the_distance(string $less_than_one, string $one, string $more_than_one)\u003C\u002Fcode> – which displays an approximate human-readable string, similar to \u003Ccode>the_title()\u003C\u002Fcode>\u003C\u002Fp>\n\u003Cp>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:\u003C\u002Fp>\n\u003C\u002Fli>\n\u003Cli>\n\u003Cp>“Less than a mile away”\u003C\u002Fp>\n\u003C\u002Fli>\n\u003Cli>“About a mile away”\u003C\u002Fli>\n\u003Cli>“About %s miles away”\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>If you need to use different units or translations, can pass three \u003Ca href=\"https:\u002F\u002Fwww.php.net\u002Fmanual\u002Fen\u002Ffunction.printf.php\" rel=\"nofollow ugc\">printf-formatted\u003C\u002Fa> strings to \u003Ccode>jhgs_the_distance()\u003C\u002Fcode> to override these messages. Put \u003Ccode>%s\u003C\u002Fcode> where you want the value.\u003C\u002Fp>\n\u003Cp>If you need the \u003Cem>exact\u003C\u002Fem>, unrounded value, you can use \u003Ccode>$post->distance\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Ch3>Geocoding\u003C\u002Fh3>\n\u003Cp>\u003Ca href=\"https:\u002F\u002Fnominatim.org\u002F\" rel=\"nofollow ugc\">Nominatim\u003C\u002Fa>‘s service is used for geocoding location searches.\u003C\u002Fp>\n\u003Cp>Using it is subject to an \u003Ca href=\"https:\u002F\u002Foperations.osmfoundation.org\u002Fpolicies\u002Fnominatim\u002F\" rel=\"nofollow ugc\">acceptable use policy\u003C\u002Fa> – if you use case will involve lots of API calls, you should replace it with a paid alternative, like \u003Ca href=\"https:\u002F\u002Fdevelopers.google.com\u002Fmaps\u002Fdocumentation\u002Fgeocoding\u002Foverview\" rel=\"nofollow ugc\">Google\u003C\u002Fa>‘s.\u003C\u002Fp>\n\u003Ch3>📍 Populating latitude and longitude data\u003C\u002Fh3>\n\u003Cp>It looks for two \u003Ca href=\"https:\u002F\u002Fwordpress.org\u002Fsupport\u002Farticle\u002Fcustom-fields\u002F\" rel=\"ugc\">custom field\u003C\u002Fa> values with the keys \u003Ccode>latitude\u003C\u002Fcode> and \u003Ccode>longitude\u003C\u002Fcode> on your posts.\u003C\u002Fp>\n\u003Cp>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.\u003C\u002Fp>\n\u003Cp>You could also hook into the \u003Ccode>save_post\u003C\u002Fcode> action to populate meta whenever you create or change a post, by adding a snippet like this to your theme’s \u003Ccode>functions.php\u003C\u002Fcode>:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>function example_update_latlngs($post){\n    $location = get_field(\"location\", $post);\n    if(isset($location)){\n        update_post_meta($post, \"longitude\", $location[\"lng\"]);\n        update_post_meta($post, \"latitude\", $location[\"lat\"]);\n    }\n}\n\nadd_action(\"save_post\", \"example_update_latlngs\", 10, 3);\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>This example assumes you are using an \u003Ca href=\"https:\u002F\u002Fwww.advancedcustomfields.com\u002Fresources\u002Fgoogle-map\u002F\" rel=\"nofollow ugc\">ACF Google Map\u003C\u002Fa> 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.\u003C\u002Fp>\n\u003Ch3>Bulk-updating existing posts\u003C\u002Fh3>\n\u003Cp>If you have many posts that you need to add longitude and latitude meta to in bulk, you could add something like this to \u003Ccode>functions.php\u003C\u002Fcode>, which will run on \u003Ca href=\"https:\u002F\u002Fdeveloper.wordpress.org\u002Freference\u002Fhooks\u002Fafter_switch_theme\u002F\" rel=\"nofollow ugc\">theme activation\u003C\u002Fa>:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>function example_update_all_latlngs(){\n    $query = new WP_Query(array(\n        \"posts_per_page\" => -1\n    ));\n    foreach($query->get_posts() as $post){\n        \u002F\u002F Function from above\n        example_update_latlngs($post);\n    }\n}\n\nadd_action('after_switch_theme', 'example_update_all_latlngs');\n\u003C\u002Fcode>\u003C\u002Fpre>\n","Add location-aware geographical search to WP_Query. You can use it to power location-aware apps, such as showing a user results near them.",1602,100,2,"2021-09-06T13:29:00.000Z","5.8.0","4.0","7.0",[27,28,29,30,31],"distance","geo","haversine","location","nominatim","https:\u002F\u002Fgithub.com\u002Fjhackett1\u002Fwp-geo-search","https:\u002F\u002Fdownloads.wordpress.org\u002Fplugin\u002Fwp-geo-search.zip",0,null,"2026-04-16T10:56:18.058Z"]