Apr 08 01 |
This plugin allows you to record a location 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.
- You may also record the latitude & longitude of a location. The enhanced version of the plugin provides multiple ways to display the location using Google mapping.
- 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.

1. A screenshot 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.
Why not check out my other WordPress plugins too!
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
country_tag($post->ID);in your index.php template file to show a post’s country tag. - And this
country_tag($post->ID, false);in your single.php template file to show the post’s country tag. - Note, you’ll need this
gobal $post;declaration in your template files too if it’s not already there. - The second parameter (the default
true, orfalse) determines if it is a short or long output:- Long – Location
Australia - Short –

- Long – Location
- The widget has a single option, one of your WordPress pages. 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.
- You can also include the same popup list of countries used in the widget on your pages by adding this
country_list_countries();to your theme’s template.

2. Countries widget options.
How to Tag a Post with a Country
Using the Location section (you can set the title of this section with the first of the plugin options, see below) 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
select UK from the dropdown.
The country names provided are the names of the 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 and features.
- 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. This interface is shown in screenshot #3 below.
- A public map for your blog readers to enjoy that shows all the mapped posts and venues (more details below about the venues feature). An example of the mapping is given here showings dozens of mapped posts and venues. The map is automatically inserted by the plugin on any page or post with
<!-- adventure-map -->. - Show a location map on a post page (when the post has location data). Include a post map with the shortcode
[post_map]and optionally set the map type to ROADMAP, SATELLITE, HYBRID, or the default TERRAIN and zoom level (default 11) with[post_map type="SATELLITE" zoom="14"]. Please see Post Locations below for more options and functionality. - Several markers are used on the mapping (default colours):
- Posts are shown with a blue marker –
. - Posts with GPX data are shown with a purple marker –
. - Named waypoints in GPX tracks are shown with a green marker –
. - Venues are shown with a red marker –
. - Additional maps embedded within posts showing other locations are shown with a green marker –
. - When creating location data new locations are shown with a yellow marker –
.
- Posts are shown with a blue marker –
- In addition to the default markers, there are a number of custom markers included. Add to these as you like, the new markers go in the plugin’s
markersdirectory. There’s even an included Photoshop template. The included markers are:















- A simple yet powerful 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.
- A number of template tags are provided to optionally enhance your WordPress theme:
- To including linked country icons:
country_tag($post_ID, $short=true, $prefix='Location ', $size=15, $echo=true); - To include a popup list of countries:
country_list_countries(); - Location map links:
get_map_link($anchor_text, $post_ID=''); - Venues button:
the_map_sidebar_link($before_HTML, $after_HTML); - Show a link to all venues:
get_venues_link();
Use this template function or have the plugin automatically include a link on any page of post with<!-- venues-link -->.
- To including linked country icons:
The plugin has several advantages over other mapping plugins. For example, it doesn’t unduly load your web server, making full use of the power of the user’s browser. This also makes content more interactive, for example hovering over elevation graphs shows the data at that point of the graph dynamically.
The following screenshots give a flavour of the plugin’s rich capabilities. The size, position, etc. of each map on your pages is customisable using CSS settings (defaults are initially provided), please refer to the options screenshot #9 below.
Post Editing
The following screenshot shows the location editing interface within the WordPress editor. As well as adding a country flag attribute to posts, add Latitude & Longitude either manually (click the location on the map) or use geo-location (address, place name, etc.). The new location marker (
) can be dragged around the map to achieve an accurate position.
The location’s map marker can also be changed from the default using the marker drop-down lost.

3. The post editing Location section.
The Country column of the post listing (screenshot #1 above) is enhanced when location data is given. Posts with location data will have Geo and an indication of the quality of the data:
- Geo:
– the Latitude & Longitude are OK. - Geo:
– only one Latitude or Longitude value is provided, or the data is duplicated with another post. - Geo:
– the Latitude & Longitude are OK, but are duplicates or the administrator has blocked plotting.
Custom Markers
Alongside the default markers described above there are three ways to set custom markers:
- Venues may use their country flag as their map marker (see options screenshot #9 below).
- Custom markers can be set for individual posts (see screenshot #3 above).
- Or you may set a custom marker for a post category. The enhanced post category editing page provides this function.

4. The post category editing page.
GPX Tracks & Elevation Graphs
Upload GPX files from your, say from your GPS device, to automatically show the tracks.

5. An uploaded GPX file automatically shown with mapping.
The GPX trace will show any named waypoints with a small green marker –
. If the post that the GPX is shown in has location data the location will be shown with a purple 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.

6. A graph of elevation associated with an uploaded GPX file.
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://your-domain/path/file.gpx'>GPX Data</a>If enabled (see options below) an elevation graph will be automatically included. However, if you want to suppress the elevation graph for a specific GPX track include elevation='off' in the markup. For example:
<a href='http://your-domain/path/file.gpx' elevation='off'>GPX Data</a>Post Locations
Posts can show their location on a map. The map is easily embedded within the post with the shortcode [post_map] and you can optionally set the map type to ROADMAP, SATELLITE, HYBRID, or the default TERRAIN and the zoom level (default 11) with e.g. [post_map type="SATELLITE" zoom="14"].
The shortcode can also be inserted using quicktag buttons. In the WordPress HTML post editor the button is
and in the Visual editor the button is
.

7. Example post location map.
There are two additional attributes that can be added to the shortcode to show any number of other locations within posts. These are location (a latitude & longitude comma separated pair) and loc_name (a name for the new location). For example you might show a place of interest with:
[post_map zoom='16' type='SATELLITE' location='54.339,-2.743' loc_name='Playing Fields']
8. Example additional location map.
Main Location Map & Options
Using the enhanced mapping features within a post is easy and highly flexible. Using the mapping is explained more 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.) Here’s an example location map. 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;
9. Options.
There are six sets of options:
- Plugin – if the map should initially be shown or hidden on the WordPress post editing page.
- Venues Map Page – the page and style used to display the main venues map.
- Post Map – how maps are embedded, with a shortcode, in posts.
- GPX Processing – control processing of GPX files attached to posts.
- Elevation Chart – control elevation charts associated with attached GPX files.
- Markers – define the colours of the default markers used by each type of map, and also enable custom markers for venues and posts.
Geo RSS Feed
The Venues Map Page 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, add ?feed=venues to your blog’s main URL to access the location RSS feed. You may wish to use this, form example, to submit geo content to Google as a geo site map.)
Venues
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.)

10. The new Venues menu.
Buy the Enhanced Plugin with Google Mapping
Just £9.50
Buy the plugin and I will provide free updates forever as the plugin gets more and more features…
Version History
Enhanced Plugin:
- 10.0 – Finished custom marker release – venues an use flags, posts and categories can have custom markers.
- 9.1 – Venues can use flags as markers.
- 9.0 – Options to select marker colours.
- 8.2 – Added filter of Countries in admin lists.
- 8.1 – Added loop for Venues and sorting of custom columns.
- 8.0 – Include Venues (and/or Pages) in search results.
- 7.3 – Show custom types in WordPress “Right Now” dashboard.
- 7.2 – Post map can be for a provided custom location (i.e. not the post lat/lng). This also allows multiple post maps!
- 7.1 – Enhanced country reporting to highlight errors in geo data.
- 7.0 – Added drag-zoom feature to venues page.
- 6.4 – Initially hide or show map option & fix for initial location of new location marker.
- 6.3 – Fixed for blank line in XML feeds.
- 6.2 – Add options for map center.
- 6.1 – Post edit button for post maps.
- 6.0 – Internationalisation.
- 5.1 – Map style for post maps.
- 5.0 – Option to include a map within a post page.
- 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.
Series - WordPress Plug-ins
- Image Link WordPress Plug-in
- Last Year WordPress Sidebar Widget Plugin
- Simple Archive Plugin
- Avatars Plugin
- WordPress Post Country Plugin
(with premium Google Mapping) - Notices Ticker Plugin
- Comments with Avatars
- Simple WordPress Twitter Plugin
- WordPress Post Grouping Plugin
Start slideshow with these images








One Response to “WordPress Post Country Plugin

[...] you have my Country plug-in, you can add the country attribute to the tweet. For example, I write blog posts and mark [...]