Horje
Allows you to insert all or part of the global GeoNames database in your WordPress base. Wordpress Tutorial

Noted That:

  • To install correctly this wp-geonames.zip .
  • Fisrt Download the wp-geonames.zip to your computer
  • Extract/Open wp-geonames.zip to Your Computer.
  • Then, Find readme.txt file inside wp-geonames.zip and Open readme.txt .
  • Now, Read the Requirements of this plugin. Which Wordpress Version and PHP Version are required to run this Plugin in Your Wordpress Site.
  • Then, Follow the Tips Below.

Start the Tips:

1. First Download " wp-geonames.zip " Plugin to your Local Computer. (Click Download)

2. Then, Login to your " yourdomain.com/wp-admin " Dashboard.

/stack/wp/e1593231376d7d849d2-4597-4fa3-a6ff-1eca18f72aab.png

3. Then, Click on " Plugins " + " Add New " from left sidemenu of Dashboard.

/stack/wp/e1593231378Screenshot20.png

4. Now, Click on "Upload Plugin" button.

/stack/wp/e1593231380Screenshot-2019-4-2AddPluginsHorjeWordPress.png

 

5. Now, Browse " wp-geonames.zip "  Downloaded plugin from your computer, Where you downloaded wp-geonames.zip According to Step – 1 Above then, click on " Install Now"

/stack/wp/e15931461531577025694plugin.png

6. Now, Click on " Active Plugin"

/stack/wp/e15932313830ca45529-bf73-4101-8178-53ae60ce549f.png

7. Then, See left sidemenu. " WP GeoNames " folder is added on left sidemenu. Now, Click on " WP GeoNames " folder.

   Noted that: If you do not see " WP GeoNames " folder on left sidemenu then, see at left sidemenu " Settings " or " Tools ".

8. Now you configure yourself oR Watch video tutorial below about  WP GeoNames Configurtions and Settings or How to work " WP GeoNames " in your WordPress site.

 

oR

After Activated Plugin According to Step-6 then,

  1. Go to " Plugins " + " Installed Plugin " from Wordpress Admin Panel Leftside Menu.
  2. or Direct go to: https://yourdomain/wp-admin/plugins.php
  3. Then, Find " WP GeoNames " Activated Plugin from Plugin List.
  4. Then, Click on " Settings " from Plugin that is WP GeoNames
  5. Now, Edit/Add/Config the setting and Click on " Save Changes " button,
WP Plugin Setting



Guide

Install and Activate

  1. Unzip the downloaded wp-geonames zip file
  2. Upload the wp-geonames folder and its contents into the wp-content/plugins/ directory of your WordPress installation
  3. Activate WP GeoNames from Plugins page

Insert GeoNames data

  1. Go to the new tab in Settings : WP GeoNames
  2. Select the GeoNames file you want
  3. Select Columns you want to insert (latitude, longitude, population, elevation…)
  4. Select type of data you want (city, building, lake, mountain…)
  5. Click ADD

You can insert as many file as you want.

Use

You must use the WordPress tools to get the database. WPDB is your friend .
You can write the code directly in your template or in functions.php of your theme.

Name of the table : ($wpdb-> prefix)geonames

Names of the columns :

  • idwpgn (bigint)
  • geonameid (bigint)
  • name (varchar)
  • asciiname (varchar)
  • alternatenames (text)
  • latitude (decimal)
  • longitude (decimal)
  • feature_class (char)
  • feature_code (varchar)
  • country_code (varchar)
  • cc2 (varchar)
  • admin1_code (varchar)
  • admin2_code (varchar)
  • admin3_code (varchar)
  • admin4_code (varchar)
  • population (bigint)
  • elevation (int)
  • dem (smallint)
  • timezone (varchar)
  • modification_date (date)

Feature Class & Code here .

Example : get GPS position for a specific city in a specific country :


global $wpdb;
$s = $wpdb->
get_row("SELECT latitude, longitude FROM ".$wpdb->
prefix."geonames WHERE name='Paris' and country_code='FR' ");
echo $s->
latitude . " - " . $s->
longitude;

Example : 10 most populous cities in Switzerland :


global $wpdb;
$s = $wpdb->
get_results("SELECT name, population FROM ".$wpdb->
prefix."geonames WHERE country_code='CH' and feature_class='P' ORDER BY population DESC LIMIT 10");
foreach($s as $t) { echo $t->
name. " : " . $t->
population . "
"; }

Example : hotels within 40 km from Marbella (ES) :


global $wpdb;
$p = $wpdb->
get_row("SELECT latitude, longitude FROM ".$wpdb->
prefix."geonames WHERE name='Marbella' and country_code='ES' ");
$dlat = 40 / 1.852 / 60;
$dlon = 40 / 1.852 / 60 / cos($p->
latitude * 0.0174533);
$s = $wpdb->
get_results("SELECT name, latitude, longitude FROM ".$wpdb->
prefix."geonames WHERE country_code='ES' and feature_code='HTL' and latitude<".($p->
latitude+$dlat)." and latitude>
".($p->
latitude-$dlat)." and longitude<".($p->
longitude+$dlon)." and longitude>
".($p->
longitude-$dlon)." LIMIT 100");
foreach($s as $t) { $d = (floor(sqrt(pow(($p->
latitude-$t->
latitude)*60*1.852,2)+pow(($p->
longitude-$t->
longitude)*60*1.852*cos($p->
latitude * 0.0174533),2)))); if($d<=40) echo $t->
name. " : " . $d . " km
"; }

Example : Suggest cities during the typing by the user (like Google search)

You must use Ajax action and PHP function with the name “wpgeonamesAjax”

In your theme, in function.php ; add :
function wpgeonamesAjax() {
global $wpdb;
$s = $wpdb-> get_results(“SELECT name
FROM “.$wpdb-> prefix.”geonames
WHERE country_code=’FR’ and feature_class=’P’ and name LIKE ‘”.strip_tags($_POST[“city”]).”%’
ORDER BY name
LIMIT 10?);
foreach($s as $t) {
echo ‘

‘.$t-> name.’

‘;
}
}

In your theme, in the right page ; add :




allows , insert , part , global , geonames , database , base , tutorial ,

Name

Read Article
https://develop.horje.com/learn/1434/reference