WP Geocode is a WordPress plugin which enables you to leverage geographic information about your blog readers.

If you’ve been doing business online for any length of time, you already understand the value of researching the data available about your web site viewers. Tools like Google Analytics is a great help because it shows you valuable data about the viewers of your web site. The problem is that it this data is not exactly timely. That’s where WP Geocode comes in.

WP Geocode let’s you create content customized for the individual user based on where they are when they view your site.
Imagine you want to target folks in a local shopping mall. Perhaps, they’re in a local coffee shop on a wifi connection. We’d simply need to get the latitude and longitude coordinates of the coffee shop and use those in our wordpress post.

There are two types of shortcodes implemented by wpgeocode. The first is data shortcodes. These are shortcodes which enable you to utilize geocode data in your posts or pages. For example, [wgc_city] will be replaced by the city of the current reader of your post or page. The second type of shortcode implemented by wpgeocode is a conditional shortcode. These enable you to conditionally include content if specific geocode conditions are met. For example, [wp_is_state_code state=’PA’] SOME TEXT [/wp_is_state_code] will display SOME TEXT for readers of the page or post that are currently in PA. For full details, see http://www.wpgeocode.com

Plugin Statistics

[wpws url = “http://wordpress.org/extend/plugins/wpgeocode/stats/” selector=”div .col-3 p” cache=”60″ timeout=”3″ error=”cache”]


Use these shortcodes to incorporate reader geolocation data into your blog posts
[wpgc_ip] – IP Address of the reader
[wpgc_city] – City of the reader
[wpgc_state_name] – State name of the reader
[wpgc_state_code] – Two letter State code of the reader
[wpgc_postal_code] – Five digit Postal code of the reader (eg: [wpgc_postal_code])
[wpgc_country_name] – Country name of the reader
[wpgc_country_code] – Two letter Country code of the reader
[wpgc_latitude] – Latitude of the reader
[wpgc_longitude] – Latitude of the reader
Conditional Shortcodes – Only available in the body of the post
Use these shortcodes to display customized content in your blog posts to readers

[wpgc_is_city_and_state city=”Yardley” state_code=”PA”]
[wpgc_is_ip ip=”xx.xx.xx.xx”]
[wpgc_is_not_ip ip=”xx.xx.xx.xx”]
[wpgc_is_city city=””]
[wpgc_is_not_city” city=””]
[wpgc_is_nearby”] – Uses the value you specify in the Nearby Range setting from the administrative panel
[wpgc_is_within miles=”10″]
[wpgc_is_within kilometers=”12″]
[wpgc_is_country_name country_name=””]
[wpgc_is_country_code country_code=””]
[wpgc_is_state_name state_name=””]
[wpgc_is_state_code state_code=””]
[wpgc_is_not_country_name country_name=””]
[wpgc_is_not_country_code country_code=””]
[wpgc_is_not_state_name state_name=””]
[wpgc_is_not_state_code state_code=””]


[wpgc_is_nearby] Hi Neighbor! [/wpgc_is_nearby] – Will display “Hi Neighbor!” to readers within a configurable distance from your home base.
[wpgc_is_within miles=10] Stop on over, since you’re in the area.[/wpgc_is_within] – Will display “Come on over!” in the post body if the user is viewing the post from within 10 miles.
[wpgc_is_ip ip=] I used to own this IP Address [/wpgc_is_ip] – Will display the message only if the user has that specific IP Address.
[wpgc_is_city city=”Yardley”] Hello Fellow Yardlian [/wpgc_is_city] – Will display the message only if the user has that specific IP Address.

More Examples

There are several pages on this blog that incorporate examples of WPGeocode:

21 Replies to “WPGeocode”

  1. This is a great plugin. I just wished that it would have an option to get the location of not only the reader but the post author as well and lock that in the post. That way you can only show that post to the people in that city or state. I’m working on a dating site and this would make everything so easy because right now I have to ask the profile owners to enter their location and also ask viewer to filter the location that they want to see posts from.

  2. Just wanted to stop by and thank you for making a great plugin. This has tremendously saved me time, and I want to say thanks for doing such a fine job with it.

    1. I did have a quick question about this plugin though. How would I be able to get it to work with Super Cache? I don’t want it to cache the specific content that I put for each state.

  3. This looks like the plugin I need, although I am based in the UK is there a way to make it work for the UK or are you planning a UK release? regards Alistair

  4. Hi. Thanks for the nice plugin. Looks though as if it only works for USA am I correct? When I run it for my locality which is Johannesburg, South Africa it does not show anything but when I run it through HideMyAss proxy for Chicago it works like a charm. Please let me know, thanks.

  5. Is there a way to configure the [wpgc_is_city city=””] shortcode so that it will cover a radius behind the city that is listed. For example, if I set [wpgc_is_city city=”Philadelphia”] is there a way to include areas in a ten miles radius around it?

    1. John,

      No – unfortunately the city shortcodes don’t work on a radius. There is, however the is_near shortcode that provides similar functionality… you need to configure a home latitude/longitude in the wpgc options panel… hope this helps.


  6. Great plugin. I have a question. I do promote cpa offers. I have a landing page (full width) designed for US traffic.
    When a user enters the LP and it’s not in the US, is it possible to redirect to another LP on the same website with a different offer for that country?
    Best regards

  7. Great Plugin.

    I did a lot of searching for free and paid plugins to use on my site for GEO location based content serving. This works really well for me as I use Amazon associates and I can filter templates to serve relevant country product details and pricing.

    However, the BIG PROBLEM I have at the moment is that my site has the latest WordPress 3.8 installed and this GEO plugin messes up my posts screen screen, it seems to mess up the jquery code for showing many of my other accordion menus in post screen.

    The front end works brilliantly but the back end/admin needs the author to do some css or jquery mods to make it compatible with WP3.8

    You can see this in action on my site @ this page: http://www.getreview.org/matricom-mx2-matricom-g-box-midnight-mx2-dual-core-xbmc-android-4-2/

    Keep up the great work.

    Julie (UK)

  8. Ooops, almost forgot to mention that if you want an intermediate fix to the WP3.8 post edit problem then you can configure wp-geocode from the settings menu.

    Edit the file => http://www.yoursite.com/wp-content/plugins/wpgeocode/wpgeocode.php

    Comment out (Line 18 – wpgeocode.php):

    add_action(‘admin_menu’, ‘wpgc_add_options_page’);

    // add_action(‘admin_menu’, ‘wpgc_add_options_page’);

    FTP the file back to the server, or even edit the file in the plugin editor in wordpress.

    This fix solves the problem but once you make the change then you can’t see the admin wpgeocode settings – but I guess you can un-comment the change to make any settings changes and then re-comment the line 18 as above.

    Hope this helps.

    Julie (UK)

    1. Julie – thanks for taking the time to let me know about this error. I’ve located what I believe to be the cause of the error… it’s a namespace issue. I’m using a toggleVisibility javascript function that appears to be in use elsewhere. I’ll be updating the plugin on wordpress.org/extend/plugins shortly.

      thanks again!

  9. Hi, your solution for Geo Coding may work perfectly for what I am trying to do. I have a single page site design that has 100 plus city locations where services are offered. What I want to be able to do is have one page that comes up in the search engines in the city where the person is located. If the city matches one where services are offered then the site will show up in Google, Yahoo and Bing along with local business directories.

    Can this be achieved with this solution? Does a location page need to be made for each city or can this be done just through the database association?

    I look forward to hearing back from you. Thank you.

  10. LOVE this plug in. I am sure I read somewhere that you have set up the code so that if I wanted to get the paid database, it would work. I need the accuracy of the GeoIP2 city database. Can you tell me if this will work?



    1. I’m also interested in this. Or, is there a way to add an IP or range of IPs to the existing database? It seems to work fine for the most part, but not for a colleague of mine, so at the very least I’d like to ensure his IP is in the DB. I’m new to this and not totally sure how it works, (ie: does the plugin create a local DB of all the countries/codes, or does it reference a live MaxMind one?). Thanks!

  11. Love this plugin. We use it on our US sites to make sure that visitors visiting our site from the Great Britain and Ireland, get routed to our UK shopping cart. Works well.
    However, and I have brought this up before, we occasionally get customers in the US, who get routed to the UK cart. In most cases they seem to have an IP address that associates them with the ISP SBCGlobal.net, or sometimes and AT&T ISP connection.
    Is there some sort of fix for this? We had a customer yesterday who was in Nevada, and was being routed to the UK cart….she finally called in and one our support reps took care of her.
    Would really like to be able to resolve this one issue with the plugin.


    LC Technology Int’l

Leave a Reply

Your email address will not be published. Required fields are marked *