Adding GeoRSS Functionality to WordPress
If you would like to give your WordPress RSS feed full GeoRSS compatibility, it’s really quite simple – all you need to do is copy and paste the following piece of code into your functions.php file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | function geo_header() { echo 'xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:georss="http://www.georss.org/georss"'; } add_action('rss2_ns', 'geo_header'); function geo_points() { global $wp_query; $gd = getGeoData(); $map_lat_geo = get_post_meta($wp_query->post->ID, 'map_lat', true); $map_long_geo = get_post_meta($wp_query->post->ID, 'map_long', true); echo '' . $map_lat_geo . ''; echo '' . $map_long_geo . ''; echo '' . $map_lat_geo . ' ' . $map_long_geo . ''; } add_action('rss2_item', 'geo_points'); |
However, please remember that in order to view the GEO-Tagged RSS feed, you will need to use the full URL, such as http://yourdomain.com/?feed=rss2
You may be asking how can you then add coordinates to posts?
Also relatively simple – just create custom fields labeled:
- map_lat
- map_long
As referenced above within the code related to the get_post_meta tags…
Congratulations on the launch – looking forward to hearing how this can be done for comments and BuddyPress activity streams, as you have with gMaps…
can you please give an example of how the geo feed output is displayed?
thanks
As soon as our LIVE demo becomes available, we will be able to demonstrate how this works.
However, if you look at the source code for the feed from an early beta version of gMaps – http://klews.net/maps/feed/ – you will see what gets injected…