Skip to content

Instantly share code, notes, and snippets.

@leoken
Forked from sta1r/feed-georss.php
Created October 16, 2013 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leoken/7010241 to your computer and use it in GitHub Desktop.
Save leoken/7010241 to your computer and use it in GitHub Desktop.
<?php
/*
GeoRSS formatted output for Google Maps
Authors: Alastair Mucklow, Chris Toppon
*/
//header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
//$more = 1;
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'" standalone="yes"?'.'>'; ?>
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:georss="http://www.georss.org/georss"
xmlns:woe="http://where.yahooapis.com/v1/schema.rng"
xmlns:media="http://search.yahoo.com/mrss/">
<title><?php bloginfo_rss('name'); echo ' - '; wp_title_rss(); ?></title>
<link rel="self" href="<?php self_link(); ?>" />
<link rel="alternate" type="text/html" href="<?php bloginfo_rss('url') ?>"/>
<subtitle><?php the_category_rss(); ?></subtitle>
<updated><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></updated>
<generator uri="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></generator>
<?php while( have_posts()) : the_post();
$geoLat = get_post_meta($post->ID, 'geoLat', true);
$geoLon = get_post_meta($post->ID, 'geoLon', true);
$coords = $geoLat.' '.$geoLon;
if ($geoLat && $geoLon) :
?>
<entry>
<title><?php the_title_rss() ?></title>
<link rel="alternate" type="text/html" href="<?php the_permalink_rss() ?>"/>
<published><?php echo mysql2date('r', get_the_time('Y-m-d H:i:s')); ?></published>
<updated><?php echo mysql2date('r', get_the_modified_time('Y-m-d H:i:s')); ?></updated>
<content type="html"><![CDATA[<div class="window"><p>Snapshot blog post: <a href="<?php the_permalink_rss() ?>">Read original</a></p><p><?php the_post_thumbnail('thumbnail'); ?></p><p><?php the_excerpt_rss(); ?></p></div>]]></content>
<author>
<name><?php the_author(); ?></name>
<uri>?php the_author_posts_link(); ?></uri>
</author>
<link rel="enclosure" type="image/jpeg" href="<?php //the_post_thumbnail('large'); ?>" />
<georss:point><?php echo $coords ?></georss:point>
<geo:lat><?php echo $geoLat ?></geo:lat>
<geo:long><?php echo $geoLon ?></geo:long>
</entry>
<?php endif; endwhile; ?>
</feed>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment