A feast of (RSS) feeds

RSS feed buttonWordPress doesn't just publish the all-posts feed: in fact, it automatically publishes feeds to just about everything on your blog. Below are a few examples; I've included both the URL and the code to automatically generate the relevent link; after all, the feed's no use if your readers can't find it.

URLs given assume you've set up pretty permalinks in Settings > Reading. Edit the bits in bold to fit your own blog's information.

all comments

URL: http://domain.com/comments/feed/
PHP code: <? bloginfo('comments_rss2_url'); ?>

posts in single categories

This is useful if your blog covers a range of topics, where people might prefer to select the topics they subscribe to rather than reading everything. The URL for the feed for any given category looks like
http://domain.com/category/category-name/feed/
or if it's the child of another category,
http://domain.com/category/parent-category/category-name/feed/

Here's the PHP code for a list of your categories with an icon at the end of each one:
<?
wp_list_categories('orderby=name&feed_image=http://domain.com/rssicon.png&depth=1&show_count=0');
?>
Things you might want to change:

  • remove the feed_image parameter and instead include feed=link text if you prefer a text link to the feed
  • show_count 1 to show the number of posts in each category; 0 to not show it (this is the default).
  • orderby selects the way categories are sorted. name sorts by name, count by number of posts, ID by the numerical ID you can find in WP admin.
  • depth refers to the number of levels of child categories you want to include: 0 for all categories with all children (this is the default), 1 shows only top-level categories, 2 shows only top- and second-level categories and so on. 0 will show child categories nested under their parent; if you want to show them as a flat list, use -1.

Find more options for this lovely function in the Codex.

You can get the tiny RSS icon from feedicons.com; don't forget to update the code to reflect the icon's location on your server.

posts with specific tags

WordPress produces feeds for individual tags with a similar structure to those for categories:
http://domain.com/tag/tag-name/feed/
However, these don't appear to work with Feedburner yet; as of time of writing, Google just redirects them back to the main all-posts feed.

posts by an individual author

Obviously this one's only really useful if your blog has more than one writer!
URL: http://domain.com/author/author-name/feed/
PHP code: <a href="<? bloginfo('url'); ?>/author/<? the_author_ID(); ?>/feed/">author's posts' feed</a>

comments on a single post

useful if you have long-running comments threads; readers can subscribe to threads which particularly interest them
URL: append /feed/ to the end of the permalink
PHP code: <? post_comments_feed_link(' your link text here '); ?>

Including other people's RSS feeds

There are times when you'll want to pull other people's RSS feeds into your blog: for example, on Who Tube we have the Dr Who-related headlines from the BBC and Outpost Gallifrey in our sidebar. There's a WordPress widget to do this for you, but if you're not using widgets, there's also a built in function which does the same job:
<? include_once(ABSPATH.WPINC.'/rss.php');
wp_rss('http://blogmum.com/feed/', 10); ?>

In the second line, the first parameter is the URL of the feed you want to include, and the second is the number of items. Pretty neat.

Share this post:
  • email
  • del.icio.us
  • Facebook
  • FriendFeed
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Twitter

Tags: , , , , , , ,

Posted by Sue on May 2, 2009 in WordPress.

5 comments to "A feast of (RSS) feeds"

  1. I love watching videos online specially on Youtube. There are lots of music clips, movie clips and instructional videos on Youtube. I love em all.

  2. Brandon Scott wrote:

    i use Youtube to watch Taylor Swift videos. I always watch movie clips on Youtube. What an awesome site. -

  3. Paige Flores wrote:

    Feedburner is really very useful for syndicating feeds from other websites."`*

  4. Louie Holmes wrote:

    i always use feedburner to syndicate my blog posts to other subscribers.;-~

  5. Lucas Parker wrote:

    i always use feedburner to syndicate my blog posts to other subscribers.''.

Leave a Reply