Apr 08 01
avatar

This plugin allows you to record a country against your posts. For example the country that the post talks about, the event took place in, the location you are writing the post from, etc. Your imagination is the limit…

Some of the key features are:

  • Once a post is tagged with a country the plugin allows flag icons to be added to your blog’s pages with simple additions to your template files.
  • Country icons can be clicked to take the user to posts from that country.
  • A sidebar widget that provides a popup to navigate to posts from a given country.
  • Presents an admin page, under the WordPress Tools menu, to review numbers of posts from each country.

I’m quite pleased with the plugin, so it’s available to share, I hope you enjoy it too. :oops:

post-listing

1. A screen shot showing posts tagged with country flag icons.

The plugin is available as a download for free here.

All I ask is that you credit the plugin, for example, include a link to this page or maybe add a link to your WordPress blogroll.
Or, perhaps please consider purchasing the enhanced version. See below…

:star: Why not check out my other WordPress plugins too! :star:

Instructions & Installation

  • Just put the complete un-zipped plugin directory into your WordPress plugin directory (if this doesn’t make sense it probably isn’t something you should be trying :-) ) and activate it.
  • Within the WordPress loop, use this <?php country_tag($post->ID); ?> in your index.php template file to show a post’s country tag.
  • And this <?php country_tag($post->ID, false); ?> in your single.php template file to show the post’s country tag.
  • Note, you’ll need this <?php gobal $post; ?> declaration in your template files too if it’s not already there.
  • The second parameter (the default true, or false) determines if it is a short or long output:
    • Long – Location Australia Australia
    • Short – USA
  • The widget has a single option, a page. When set to one of your pages a link is shown under the popup list of countries in the widget. Following the link goes to that page – where you might show a list of countries featured on your blog, or a map! A map is easily created with the enhanced version of this plugin (see below).
  • You can also include the same popup list of countries used in the widget on your pages by adding this <?php country_list_countries(); ?> to your theme’s template.

How to Tag a Post with a Country

Using the In which Country was the Adventure? section of the post writing page. Select the Country you want to tag the post with from the country dropdown. For example, to get a UK flag UK select UK from the dropdown.

The country names provided are the names of the flag icon files in the directory:

wp-content/plugins/post-country/Flags/

Feel free to add additional flag icon files or remove those you don’t want to see listed in the dropdown.


Premium Version of the Plugin with Mapping

The standard plugin allows Latitude & Longitude to be stored along with the country tag. Google mapping is available with an enhanced version of the plugin available to buy below. An example of the mapping is given here showings dozens of mapped posts and venues.

The enhanced plugin provides several advanced mapping interfaces.

  • Within the WordPress post writing interface a sophisticated interface (including geo-location by address, place name, etc.) to create and manage the location associated with posts.
  • A public map for your blog readers to enjoy that shows all the mapped posts and venues (see below for details about the venues feature).
  • Four markers are used on the mapping:
    1. Posts are shown with a blue marker – post-marker.
    2. Posts with GPX data are shown with a purple marker – post-marker.
    3. Venues are shown with a red marker – venue-marker.
    4. When creating location data new locations are shown with a yellow marker – new-marker.
  • A simple mechanism to allow uploaded GPX files (e.g. from a GPS enabled device) to be automatically represented with Google mapping showing the trace of a route. These routes may also be accompanied with a graph showing elevation along the route.

location-box

2. The enhanced In which Country was the Adventure? box.

gpx-file-trace

3. An uploaded GPX file automatically shown with mapping.

Th GPX trace will show any named points with a small green marker – waypoint. Also if the post that the GPX is shown in has location data the location will be shown with a marker – post-marker.

Accompanying maps of GPX tracks, graphing of the elevation along the path of the track may be displayed. Graphs are built dynamically by the user’s browser using Google Charts (so unlike some other plugins they do not cause lots of PHP processing on your server or blow PHP’s memory limits). Here’s an example of the graph that accompanies the track above.

gpx-elevation-graph

4. A graph of elevation associated with an uploaded GPX file.

Using the enhanced mapping features within a post is easy and highly flexible. Using the mapping is explained in detail here.

Mapping of all tagged posts (and Venues, see below) can be presented to your users on a nominated page. (The blog administrator can elect to not display the location of specific posts even when latitude & longitude values have been supplied.) The page used to display the map is defined on the plugin options page. That page should have the following simple code within its text to show the map.

<!-- adventure-map -->

Note, the options page also provides a field to enter the CSS for the map canvas. It is essential that this sets, as a minimum, the size of the canvas. To kick-off try something like:

width: 600px; height: 450px; border: 1px solid #ddd; margin: 5px;

options

5. Options.

The first two options allow configuration of whether location data, for posts and/or venues, are included in the standards compliant Geo RSS feed generated by the plugin. (Note, the location RSS feed is accessed by adding ?feed=venues to your blog’s main URL. You may wish to use this, form example, to submit geo content to Google as a geo site map.)

GPX files may be uploaded using the normal WordPress media upload and then embedded within a post. For example, the following simple markup will be automatically presented with a Google map showing the route described by the GPX file.

<a href='http://domain/path/file.gpx'>GPX Data</a>

In addition to tagging posts with country and latitude & longitude for mapping the enhanced plugin provides a special type of post – Venue. These are great for recording specific details about specific locations. For example, a page of information for each country, or a page of details (e.g. pubs, clubs, and hotels) about a particular city. Venues are a blend between standard WordPress pages and posts. Venues are accessed from the new Venues menu. (Note that the list of countries moves with the enhanced version of the plugin from the WordPress Tools menu to the Venues menu.)

venues-menu

6. The new Venues menu.


Buy the Enhanced Plugin with Google Mapping

Buy the enhanced Post Country Plugin here for an insanely cheap price!
Just £9.50


Version History

Enhanced Plugin:

  • 4.3 – Elevation graphs matched to GPX tracks.
  • 4.2 – GPX files can be shown as maps with tracks in posts.
  • 4.1 – Trap for a marker in the same place as another.
  • 4.0 – Google mapping of posts and venues with location data.
  • 3.0 – Venue post-type to record location, beta, facts, links, etc. for given locations.

Standard Plugin:

  • 2.0 – Version without mapping.
  • 1.3 – Various lookup widget bug fixes.
  • 1.2 – Don’t duplicate meta data.
  • 1.1 – New admin summary page.
  • 1.0 – Added custom form entry to aid user experience, plus now adds Latitude & Longitude.
  • 0.4 – Added custom column to posts management list to show country.
  • 0.3 – Fixed bug wih where clause construction; thanks to Thomas Lindholm.
  • 0.2 – Released to the WordPress community.
  • 0.1 – Initial version.

Thanks!

With regret comments are closed on this post to avoid being deluged with “how to” queries and not genuine issues with the plugin. So, if you want support or advice use the Feedback link. But please note I will ask for a donation before I’ll look at “how to” questions, I can’t teach PHP programming for free.

Article Series - WordPress Plug-ins

  1. Image Link WordPress Plug-in
  2. Last Year WordPress Sidebar Widget Plugin
  3. Simple Archive Plugin
  4. Avatars Plugin
  5. WordPress Post Country Plugin
    (with premium Google Mapping version)
  6. Notices Ticker Plugin
  7. Comments with Avatars
  8. Simple WordPress Twitter Plugin
  9. WordPress Post Grouping Plugin
slideshow
Start slideshow with these images

One Response to “WordPress Post Country Plugin
(with premium Google Mapping version)”

Comments are closed.
Please use the feedback link to send any comments to the adminstrator.