Für einen Kunden erstelle ich gerade einen neuen Berichterstattungs-Blog für die Musik Events Chiemsee Reggae Summer und Chiemsee Rocks.
Ein Knackpunkt war der, dass im RSS Feed auch die Artikel und Podcasts (!) der vergangenen Jahre enthalten sein soll.
Hätte es sich hierbei nur um die Artikel gehandelt, hätte man diese einfach importieren können, die Podcasts allerdings erschwerten das ganze ein bisschen.
Lösung:
Verantwortlich für die (dynamische) Erstellung des (RSS2) Feeds ist bei WordPress die Datei feed-rss2.php, welche im Verzeichnis wp-includes/ liegt.
Die PHP-Datei sieht bei mir so aus:
[spoiler title=“feed-rss2.php“ open=“0″ style=“1″]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
<!--?php <!--?php /** * RSS2 Feed Template for displaying RSS2 Posts feed. * * @package WordPress */ 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').'"?'.'-->'; ?> >< ?php bloginfo_rss('name'); wp_title_rss(); ?> <link />< ?php bloginfo_rss('url') ?>< ?php bloginfo_rss("description") ?>< ?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?>< ?php bloginfo_rss( 'language' ); ?>< ?php echo apply_filters( 'rss_update_period', 'hourly' ); ?>< ?php echo apply_filters( 'rss_update_frequency', '1' ); ?> < ?php do_action('rss2_head'); ?> < ?php while( have_posts()) : the_post(); ?>< ?php the_title_rss() ?> <link />< ?php the_permalink_rss() ?> < ?php comments_link_feed(); ?> < ?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?> < ?php the_author() ?> < ?php the_category_rss('rss2') ?> < ?php the_guid(); ?> < ?php if (get_option('rss_use_excerpt')) : ?> < ![CDATA[<!--?php the_excerpt_rss(); ?-->]]> < ?php else : ?> < ![CDATA[<!--?php the_excerpt_rss(); ?-->]]> < ?php $content = get_the_content_feed('rss2'); ?> < ?php if ( strlen( $content ) > 0 ) : ?> < ![CDATA[<!--?php echo $content; ?-->]]> < ?php else : ?> < ![CDATA[<!--?php the_excerpt_rss(); ?-->]]> < ?php endif; ?> < ?php endif; ?> < ?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?> < ?php echo get_comments_number(); ?> < ?php rss_enclosure(); ?> < ?php do_action('rss2_item'); ?> < ?php endwhile; ?> |
[/spoiler]
Ergänzt kann das jetzt nach dem endwhile und vor </challel> und </rss>:
1 2 3 4 5 6 7 8 9 |
<item> <title>Stefan Dettl (CRS2012)</title> <link />http://www.mahogany-management.com/CRS/podc/Stefan%20Dettl.mp3 <description></description> <pubdate>Sun, 26 Aug 2012 20:30:00 GMT</pubdate> <guid isPermaLink="false">{8C893946-943A-4748-A29D-204EDB4921C9}</guid> <author>info@stoeckel-friends.de (Robert Porzenheim)</author> <enclosure url="http://www.mahogany-management.com/CRS/podc/Stefan%20Dettl.mp3" length="3665092" type="audio/mpeg"></enclosure> </item> |
Und schon hat man ein weiteres (statisches) Item zu dem dynamischen RSS-Feed hinzugefügt! 🙂