Fun With Wordpress Feeds
The more I use Wordpress, the more I come to view it as one big goody bag of useful functions. While working on my Wordpress-powered article directory, I discovered a very useful capability of the wp_list_categories() function. That capability being the ability to automatically list an RSS feed link (with optional icon) next to the category. This got me thinking about what other capabilities were available for Wordpress feeds.
After doing some quick Googling, I found the Wordpress Codex page on Wordpress Feeds. This is a great resource because it shows you how to call your Wordpress feed link via template tags in either RSS 1.0, RSS 2.0 or Atom flavors, how to add icons to your feed link and how to rewrite your RSS feed URL to suite your preferences. There are also a few resources listed there that show you how to further customize your feeds.
According to the Wordpress documentation, the following feed URLs are available to you:
With Permalinks
http://example.com/feed/
http://example.com/feed/rss/
http://example.com/feed/rss2/
http://example.com/feed/rdf/
http://example.com/feed/atom/
Without Permalinks (direct file access)
http://example.com/wp-rss.php
http://example.com/wp-rss2.php
http://example.com/wp-rdf.php
http://example.com/wp-atom.php
Without Permalinks (dynamic URL)
http://example.com/?feed=rss
http://example.com/?feed=rss2
http://example.com/?feed=rdf
http://example.com/?feed=atom
Category feed
http://example.com/wp-rss2.php?cat=42
or
http://example.com/category/categoryname/feed
Global Comments Feed
http://example.com/comments/feed/
http://example.com/comments/feed/rss/
http://example.com/comments/feed/rss2/
http://example.com/comments/feed/atom/
Single Post Comments Feed
http://example.com/category/post/comments/feed/
http://example.com/comments/category/post/feed/rss/
http://example.com/comments/category/post/feed/rss2/
http://example.com/comments/category/post/feed/atom/
Keep in mind that your permalink settings will change the location of your feed URLs. If you read through the Wordpress documentation and click through to the related resources, you'll find that there are numerous ways to present feeds from your Wordpress blog. Which way you choose will depend on your personal preferences, the preferences of your visitors, and your particular objectives for presenting your feed.
So, how is this information useful for the average Wordpress blogger?
Knowing how your Wordpress blog presents your data and finding ways to capitalize on that functionality is important for any blogger. For instance, you may want to track how many people are subscribing to your RSS feeds. If you're using the Feedburner FeedSmith plugin, this process is much simpler, but you still need to take into consideration that some visitors may only subscribe to comments and not your main feed. Therefore, you need to configure Feedburner to take your comments feed into account.
A common question I've seen asked is how to present a list of categories, recent comments or recent posts on a page. While there are plugins out there that will do this for you, some are limited in their functionality and do not give you ultimate flexibility in how to present your data. Here are three examples of presenting your feeds in your content that use the native Wordpress fetch_rss function or the wp_list_categories() function and the PHP Exec plugin.
10 Most Recent Posts
The Code:
<phpcode>
<h2><?php _e('10 Most Recent Posts'); ?></h2>
<?php // Get Feed(s)
include_once(ABSPATH . WPINC . '/rss.php');
$rss = fetch_rss('http://jmorris.name/blog/feed/');
$maxitems = 10;
$items = array_slice($rss->items, 0, $maxitems);
?>
<ul>
<?php if (empty($items)) echo '<li>No items</li>';
else
foreach ( $items as $item ) : ?>
<li><a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'><?php echo $item['title']; ?></a></li>
<?php endforeach; ?>
</ul>
</phpcode>
The Output:
10 Most Recent Posts
- The Stupidest Post I Ever Read…
- Rockin Out for 2010
- 2009 in Review
- TwakeUp! Breast Cancer Effects Us All!
- Ode to SEOs
10 Most Recent Comments
The Code:
<phpcode>
<h2><?php _e('10 Most Recent Comments'); ?></h2>
<?php // Get Feed(s)
include_once(ABSPATH . WPINC . '/rss.php');
$rss = fetch_rss('http://jmorris.name/blog/comments/feed/');
$maxitems = 10;
$items = array_slice($rss->items, 0, $maxitems);
?>
<ul>
<?php if (empty($items)) echo '<li>No items</li>';
else
foreach ( $items as $item ) : ?>
<li><a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'><?php echo $item['title']; ?></a></li>
<?php endforeach; ?>
</ul>
</phpcode>
The Output:
10 Most Recent Comments
- Comment on TwakeUp! Breast Cancer Effects Us All! by Khan
- Comment on Use rel=nofollow Only When Needed by albuquerque web design
- Comment on [Quick Review] Compaq Presario F755US Laptop + XP Driver Package Download! by sarah
- Comment on The Stupidest Post I Ever Read… by Geek Tees
- Comment on The Stupidest Post I Ever Read… by David Leigh
Categories With Post Count and Feed Link
The Code:
<phpcode>
<ul>
<?php
wp_list_categories('orderby=name&show_count=1&feed_image=/images/lilrss.gif&title_li=<h2>Categories</h2>');
?>
</ul>
</phpcode>
The Output:
-
Categories
- Advertising
(2)
- Announcements
(19)
- Audiophile
(1)
- Automobiles
(2)
- Blogging
(10)
- Computers
(4)
- Domains
(2)
- Fiction
(1)
- General
(45)
- Google
(8)
- Humor
(5)
- ImpressCMS
(3)
- Interesting
(19)
- Marketing
(6)
- Monetization
(4)
- Music
(8)
- My Sites
(1)
- Open Source
(5)
- politics
(1)
- Rant
(1)
- Search Industry
(9)
- Social Networking
(7)
- Software
(6)
- Templates
(1)
- Twitter
(2)
- Wordpress
(5)
- Advertising
Of course, these are just three examples of how you can use native Wordpress functions with your feeds. Depending on your skill level and needs, you can easily do a wide variety of useful things with your feeds. The main point is to take the time read the documentation Wordpress has provided and learn the capabilities of the system you are using.
By taking advantage of native functionality, you not only enrich the experience of your site for your visitors, but you also reduce the amount of overhead needed for additional plugins that duplicate native functionality. The fewer plugins you have, the fewer plugins that can be exploited maliciously and the fewer plugins you have to worry about keeping updated.
You have read my two cents. Now have your say!
What are some interesting tips or tricks you have for using Wordpress feeds?
Do you prefer to use the Wordpress native functionality, or do you prefer to use plugins that do the "dirty work" for you?
Very useful post, thx James. It also reminded me of sometimes how we “forget” about the documentation. Because wordpress is so easy to use we we forget to read the docs to discover these little gems of info.
I’m bad about not reading the docs or only reading them when I’m stumped on a particular problem. I think Wordpress laid their docs for people just like me.
Their docs are so easy to navigate and often times, all I have to do to find the info I’m looking for is type the function in Google with codex and bam! The first result is exactly what I needed or is only a couple clicks away.
I love all the little hidden gems in Wordpress. Every day is like a treasure hunt. What new and cool thing can I do with Wordpress today?
Thanks for stopping by!
James, I just ran across this post. This is some really great info. Thanks fo putting together this list. Like you I don’t do a good job of reading the docs either.
Docs are for wimps not real programmers
This is a really detailed blog post, I will definitly use some/all of these plugins for my blog. thanks.
You have exellent pluggins here i hope you dont mind to use some on my website.
Great post, how about put the feed plugin with dapper.net. This way you can pull many feeds from the website even they don't have the feeds! and put them on your blog.
@Len: Glad you found it helpful.
@Janni: They're not plugins so much as functions available in Wordpress, but by all means, if they are useful to you, use them to your heart's content. That's what they're there for.
@IM: Dapper looks very interesting. I'll have to check that out more and see what tricks you can do with it. Thanks for sharing the tip!
There are a ton of wordpress plugins, that are really cool and very useful. Do a google search on wordpress plugins, and have fun
Absolutely! And for most people, that's a perfectly fine way to go. For myself, I like to get under the hood and customize things a bit. It doesn't show so much here, but on client sites, I tailor the application to suite the need of the client.
I think I used this code with Yahoo Pipes to display relevant feeds on my blog.
I used to setup custom feeds for Wordpress, but the issue I kept having was that it ultimately made it much more easier for users to steal content. They would used automated bots to grab the feed, and if the feed itself was limited in characters, the bot would follow it to my site post (the source) and then steal the article there.
Wondering if there is any way around that?
I enjoy using word press, as well as using any add-ons that go along with them. I am constantly looking online for new updates as well as add-ons. I enjoyed reading the post, as well as all the replies. Its nice to see so many people who enjoy wordpress as much as I do.
Unfortunately, I too had too many problems with duplicate feeds and scrapers stealing our content so I disabled feeds.
I have used a WP blog on my website, but found that even with promoting the RSS component, I was not able to leverage the kind of traffic that I heard was possible with this.
What I would be really interested in is a plugin that allows one to know whether someone is illegally using your feed or content from scraping your feed. Is this something that is out there yet?
I also had problem with duplicate contends since most of my original article were stolen, altered and used with their name driving traffic to their site. It is ongoing battle to trying to contact these people to remove the articles, mostly without success.
I always promote custom feeds, but the feed scrapers really become a problem so I dislike doing it too much. Too much content theft on the Internet these days.
Scrappers are the scourge of the blogsphere! ARGH!
There are new plug-ins available that allow you to automatically append a copyright message into the RSS feed excerpt or post (if you use full-text feeds). It's a small matter to do a str_replace in PHP and eliminate those copyrighted messages, so it would be wise to use a small graphic with your copyright message. Then you can use the alt and title tags to make the image accessable to those with limited sight.
Google is getting much, much more advanced with detecting scrapper sites. I have a few that even scrape THIS blog. How sad is that?! Google has been penalizing the scrapers and not this site.
Still, it's not a bad idea to include your own copyright message in your feed. There are a few good WP plug-ins that make this easy to do and they only take about 5 minutes to deploy.
Thanks, very useful. I find Wordpress to be exceptional. Feeds of categories is very useful for sites that you are only interested in one feed (or even a couple) that have tons of other posts you really don’t want to clutter up your reader with.
Word Press is the bomb! It just makes it so easy to live when you consider how easy plug-ins like these make it to do exactly as you want.
Sometimes things can be “fiddly” but so far (fingers crossed) I’ve not had a single issue which couldn’t be resolved.
I started using rss feeds about 2 months ago and it is one of the best things i’ve done to date. I am an aquarium/fish tank nut, so anything i see online regarding this i immediatley upload to my wordpress.
I have never seen such a feed list frenzy.
it’s very informative, but as i use only blogspot blogs so i don’t have more information about wordpress and after reading your post i will try the wordpress.
I would be really interested in is a plugin that allows one to know whether someone is illegally using your feed or content from scraping your feed. Is this something that is out there yet? Thanks fo putting together this list. Even I should say I enjoyed reading the post, as well as all the replies.
Looks as if you can have fun with Wordpress feeds. Nice Article!
Interesting post. I have just bookmarked this at stumbleupon. Others no doubt will like it like I did.
This tutorial is a bomb!
I am newbie in terms ow Wordpress, so you saved my time.