|This article may be outdated and contain information pertaining to an older version of WordPress. Please take caution when following the procedure, as many things may have changed.|
If terms like feed, syndication, and RSS make your head spin, stop right now and read an Introduction to Syndication. That will give you a good overview of feeds and syndication. We have an article on WordPress Feeds to help you understand the basics, if you need them, but from here on, this article assumes that you know the basics of what feeds are and how they are used.
Customized feeds give your readers more information about you and your blog: you can include the names of additional collaborators on your blog posts, or a link to your Friend-of-a-Friend file. Contrariwise, it can also help you restrict the information available for syndication, by removing extraneous data or providing a machine-readable version of your copyright statement.
WordPress uses a set of feed templates to display your site's feeds, in much the same way as it uses theme templates to display your content. These feed templates are located in the main WordPress directory. These core files are not compatible with the Theme system, however it is possible to use custom page templates to achieve a theme-based solution (see further information and links below).
The following feed templates are included with WordPress:
There are a variety of ways to customize your feeds, through the use of third-party software you install and add-on to your WordPress site, or by manually changing the feed templates to meet your needs.
Some third-party web services can help you manage and customize your feeds. Using such services can be a simple way to do things like counting the number of people who read your feed, or combining your blog's feed with your Flickr photostream.
Such services include:
Editing your feed templates is much the same as editing your theme templates. However, feed templates are not integrated into the WordPress theme system; if you would like different versions of your feeds, you'll need to create extra feed templates or apply this patch (written in 2005) to your WordPress installation.
Many specialized template tags exist specifically to format your content in a way that complies with the RSS standards. They include:
Let's look at some examples of how to use these template tags with your WordPress site feeds.
With regards to the below, wp-rss2.php no longer has the pubDate command, but /wp-includes/feed-rss2.php does on lines 20, and 22.
If you are American, I suggest replacing said lines with the below:
<pubDate><?php echo mysql2date('m-d-Y', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
The default RSS 2.0 feed in WordPress 1.5 displays the date elements of posts using some language-specific terms, i.e., day and month names. If you're using a localized version (non-English) of WordPress, some feed readers may not correctly interpret these names, causing errors in display and/or validation. If you are using a WordPress version later than 1.5.1, the problem with international dates in feeds has been fixed.
To solve this problem in prior versions of WordPress, open wp-rss2.php and change the entry pubDate element from:
<pubDate> <?php echo mysql2date('D, d M Y H:i:s +0000', get_the_time('Y-m-d H:i:s')); ?> </pubDate>
<pubDate> <?php echo mysql2date('r', get_the_time('Y-m-d H:i:s')); ?> </pubDate>
The 'r' is a generic PHP date format that does not rely on translated strings.
This example sets the title of each item in your comments RSS feed from By: Harriet to Harriet on Sample Post, which helps provide some context when reading the main feed of all comments on your blog. Because the_title_rss doesn't work outside The Loop, it's necessary to duplicate part of its function in your template.
The following code should be put in wp_commentsrss2.php, just after the beginning of the comment loop:
<item> <?php /* First, grab the title of the entry on which the comment was posted */ $title = get_the_title($comment->comment_post_ID); /* Now sanitize the formatting for RSS */ $title = apply_filters('the_title', $title); $title = apply_filters('the_title_rss', $title); ?> <title><?php comment_author_rss() ?> on <?php echo $title ?></title>
Alternatively, this plugin will achieve the same result without hacking your wordpress install.
To see your new feed, you can use any of the many feed readers available on the Internet. While your feed might look good to you in the different readers, it might still have problems.
Feed formats are designed to be read and manipulated by machines; errors in your feed template can make your feed unreadable to some or all feedreaders. So after you make all your changes, it's a good idea to check that your feed meets the relevant standards. Validation services include: