1. Putting the geo position in a Wordpress RSS feed

    The last few days I've been looking at adding geographic information to articles on this website. For WordPress, the software this site is running on, I found the Geo plugin with which you can store geographic coordinates for an article. The plugin adds this information to the page of each article, but not in the RSS feed, so I made a function that does this, though not automatically.

    To use it, start with adding the following function to the Geo plugin. I'm using version 1.0, don't know if it works in earlier versions:

    /**
     * Returns the tags with geo information for inclusion in RSS 2.0 feeds.
     *
     * Include a call to this function inside the <item> tag to
     * add tags with geo information if available.
     * To keep the feed valid add these namespace declarations to the <rss> tag:
     *    xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
     *    xmlns:icbm="http://postneo.com/icbm"
     *    xmlns:geourl="http://geourl.org/rss/module/"
     */
    function get_the_rss_geotags() {
        global $wp_query;
    
        if(!get_settings('use_geo_positions')) return;
    
        list($lat, $lon) = split(',', get_post_meta($wp_query->post->ID, '_geo_location', true));
        if ($lat == '' || $lon == '') {
            if (get_settings('use_default_geourl')){
                // send the default here
                $lat = get_settings('default_geourl_lat');
                $lon = get_settings('default_geourl_lon');
            }
        }
        if ($lat != '' && $lon != '') {
            echo "<geo :lat>$lat</geo><geo :long>$lon</geo>
    "
                    . "<icbm :latitude>$lat</icbm><icbm :longitude>$lon</icbm>
    "
                    . "<geourl :longitude>$lon</geourl><geourl :latitude>$lat</geourl>
    ";
        }
    }
    

    Now you can add this line to wp-rss2.php, somewhere inside the <item> tag:

    <?php echo get_the_rss_geotags(); ?>
    

    Also remember to add these namespace declarations to the rss tag:

    <rss version=”2.0”
        xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
        xmlns:icbm="http://postneo.com/icbm"
        xmlns:geourl="http://geourl.org/rss/module/">
    

    That's it.