Before downloading this plugin you MUST first read and follow this post or it will NOT work.

OK, this is my first ever Wordpress plugin.  It came out of a need to be able to show country specific content on a Wordpress based blog. You can use it for anything from showing a simple Bonjour to French visitors to displaying geo targeted advertising. Once it’s installed it’s pretty simple to use.

Installation instructions

1. Create the geo targeting database by following the GeoTarget database setup post mentioned above.
2. Download and unzip the plugin into your plugins folder (download link below).
3. Open the GeoTarget.php file and edit the following:-

/* USER DEFINED VARIABLES HERE */
$DatabaseName = "databasename"; // your database name
$Username = "username"; // your database username
$Password = "password"; // your database password
$DatabaseServer = "localhost"; // 99% chance you can leave this set to localhost
$CookieDomain = ".yourdomain.com"; // .yourdomain.com
$CookieDuration = 3600; // default to 3600 seconds (1 hour)

4. Activate the plugin.

How to use the GeoTarget plugin

Once installed and activated you will be able to use the $country_code variable within your theme files.  It will be a 2 character string representing the country code of the user based on their IP.  It can therefore be “US”, “UK”, “FR”, etc.

Here is an example piece of code to use within a theme file to get you started:-

<?php if ( $country_code == "FR" ) : ?><p>Bonjour</p><?php else: ?><p>Hello</p><?php endif; ?>

Download version 0.1 here: GeoTarget (downloaded 371 times)

Any questions or suggestions for improvements are welcome.

Changelog

Version 0.1

16-October-2008

  • Let’s go!