Make WordPress Core

Ticket #17808: news-feed.txt

File news-feed.txt, 2.3 KB (added by heilhard, 13 years ago)

This is the actual news feed. Rename it to news-feed.php and copy it into TEMPLATEPATH.

Line 
1<?php
2/**
3 * @package WordPress
4 * @subpackage Twenty_Ten
5 */
6
7header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
8$more = 1;
9$news = new WP_query('post_type=custom_news');
10
11echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
12
13<rss version="2.0"
14        xmlns:content="http://purl.org/rss/1.0/modules/content/"
15        xmlns:wfw="http://wellformedweb.org/CommentAPI/"
16        xmlns:dc="http://purl.org/dc/elements/1.1/"
17        xmlns:atom="http://www.w3.org/2005/Atom"
18        xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
19        xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
20        <?php do_action('rss2_ns'); ?>
21>
22
23<channel>
24        <title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
25        <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
26        <link><?php bloginfo_rss('url') ?></link>
27        <description><?php bloginfo_rss("description") ?></description>
28        <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
29        <?php //the_generator( 'rss2' ); ?>
30        <language><?php echo get_option('rss_language'); ?></language>
31        <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'daily' ); ?></sy:updatePeriod>
32        <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
33        <?php do_action('rss2_head'); ?>
34        <?php if ($news->have_posts()) : while ($news->have_posts()) : $news->the_post(); ?>
35        <item>
36                <title><?php the_title_rss() ?></title>
37                <link><?php the_permalink_rss() ?></link>
38                <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
39                <dc:creator><?php the_author() ?></dc:creator>
40
41                <guid isPermaLink="false"><?php the_guid(); ?></guid>
42<?php if (get_option('rss_use_excerpt')) : ?>
43                <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
44<?php else : ?>
45                <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
46        <?php if ( strlen( $post->post_content ) > 0 ) : ?>
47                <content:encoded><![CDATA[<?php the_content_feed('rss2') ?>]]></content:encoded>
48        <?php else : ?>
49                <content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
50        <?php endif; ?>
51<?php endif; ?>
52<?php rss_enclosure(); ?>
53        <?php do_action('rss2_item'); ?>
54        </item>
55        <?php endwhile; endif; ?>
56</channel>
57</rss>