A how-to piece that goes beyond the scope of our upcoming WordPress book.
WordPress User Level: Intermediate to Advanced
WordPress has a powerful and flexible Pages feature that enables you to create Web pages that are part of your blog yet exist outside the blog chronology. You can find examples of the Pages feature on this site by clicking the links at the very top of the page; all of them except FAQ point to WordPress Pages on this site.
Note that I’m using an uppercase P when discussing this Pages feature. That’s so you don’t get confused between the generic use of page (as in Web page) and WordPress Page feature Page.
This site has a bunch of categories that can be broken down into two groups: book support categories and Maria’s WebLog categories. You can see them listed in their groups in the sidebar, with a bunch of links between them.
Although I’d like to believe that Maria’s WebLog is so incredibly fascinating that most people come here just to read it, I know that’s not true. Many people come here to get additional information and support for my books. There are a bunch of these books (61 or 62 at last count) and a handful still in print at any time. This site’s Book Support categories provide support for those books.
Why Bother with a Custom Page?
On my old support site (www.langerbooks.com), each book had its own RSS feed. I didn’t realize it until recently, but many readers were using that feed to keep apprised of new content via RSS feed reader software. As I have stated elsewhere, although I know what a newsreader is for, I don’t personally use one on a regular basis. So it wasn’t until I realized that people were looking for those old feeds that I decided to provide new feeds to replace them.
There was an easy way to do this: simply include the feed=RSS parameter in the wp_list_cats template tag I use in the sidebar. So, for example, my current use of this tag:
<?php wp_list_cats('sort_comVRr
would be changed to:
<?php wp_list_cats('sort_comVRffVVC%52r
If you’ve got sharp eyes and know WordPress, you may realize that something’s missing from that tag: the exclude parameter that enables me to break your category list into two groups without using parent and child categories. I’ll cover that in a future article.
Using that second bit of code would display (RSS) after each category name in the sidebar. RSS would be a link to the RSS feed for that category.
The trouble is, I didn’t like the way it looked. After all, who really wants to see (RSS) after every single category name in the list? It looks goofy. I didn’t like it, so I didn’t want to do it that way.
Instead, I decided to tap into the Pages feature and create my own custom Page template for listing RSS feeds.
Creating the File
To do this, start with one of the existing Pages templates. The one I picked was archives.php, which can be found with your other theme files in its theme folder.
If your theme does not include archives.php (not to be confused with archive.php), you’ll have a bit more work to do. You’ll have to get the archives.php file from the Default theme and the index.php file from your chosen theme and create a sort of hybrid with header information from archives.php inserted in index.php that has The Loop removed. If you know what I’m talking about, go for it. If you don’t, stop reading and wait for a future article about creating a Pages template when one doesn’t exist for your theme. (You may have to wait a while; comments requesting such an article might help push me to write it.)
Now with the achives.php file open in your favorite text editor (hopefully something that’s a real text editor and not a word processor), start by saving the file with the name rssfeeds.php (or something like that) in your theme’s folder — that’s the folder where your other theme files reside. Now edit the contents of the file as follows:
- Replace
Template Name: ArchiveswithTemplate Name: RSS Feeds - Delete everything that’s in the “content” of the page. In my theme, for example, that’s everything between
<div id="content">and</div>, not including those two lines. - Insert (where the lines were deleted) the codes to display the category names with the links. That can be something as simple as what’s noted above:
<?php wp_list_cats('sort_comVRffVVC%52r. Or it can be kinda fancy, like what I’ve got in my version of the file:<h1>RSS Feed Links</h1> <p>Click the icon or use the RSS link to subscribe to an RSS feed for the entire site or a specific site topic.</p> <h2>Entire Site</h2> <ul> <li><a href="http://feeds.feedburner.com/marialanger" title="Subscribe to Maria's WebLog" rel="alternate" type="application/rss+xml"><img src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="border:0"/></a></li> <li><a href="http://add.my.yahoo.com/rss?url=http://feeds.feedburner.com/marialanger" title="Maria's WebLog"><img src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif" alt="" style="border:0"/></a></li> <li><a href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url= http://feeds.feedburner.com/marialanger" title="Maria's WebLog"><img src="http://www.newsgator.com/images/ngsub1.gif" alt="Subscribe in NewsGator Online" style="border:0"/></a></li> <li><a href="http://fusion.google.com/add?feedurl=http://feeds.feedburner.com/marialanger"> <img src="http://buttons.googlesyndication.com/fusion/add.gif" width="104" height="17" style="border:0" title="Maria's WebLog" alt="Add to Google"/></a></li> <li><a href="http://www.bloglines.com/sub/http://feeds.feedburner.com/marialanger" title="Maria's WebLog" type="application/rss+xml"><img src="http://www.bloglines.com/images/sub_modern1.gif" alt="Subscribe in Bloglines" style="border:0"/></a></li> <li><a href="http://feeds.my.aol.com/add.jsp?url=http://feeds.feedburner.com/marialanger"> <img src="http://myfeeds.aolcdn.com/vis/myaol_cta1.gif" title="Maria's WebLog" alt="Add to My AOL" style="border:0"/></a></li> </ul> <table width="100%"> <tr> <td width="50%" valign="top"> <!-- BLOG CATEGORIES --> <h2>Maria's WebLog</h2> <ul><?php wp_list_cats('exclude=1,24,25,26,27,29,30,31,32&sort_comVRffVVC%52rVࠣFCࠣFBvGF#SR"fƖv'F#ࠣ$5U%B4DTt$U2ࠣƃ#&7W'C#ࠣVwƗ7E6G2vW6^ude=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,33& sort_column=name&feed=RSS'); ?></ul> </td> </tr> </table> - Save the file’s changes.
Creating the Page
Once the file has been created and saved to the appropriate folder in your themes folder, you’re all ready to use it.
- Log into your WordPress blog and use the navigation at the top of the page to get to the Write Pages administration panel.
- In the right column, choose RSS Feeds from the Page Template drop-down list.
- Click Publish beneath the Page Content box.
Sure, you can enter a page title and content in the boxes. But they’ll be completely ignored so you’ll be wasting your time. Only the tags you included in the template will appear in the page.
Using the Page
The last step is to link the page to your site. If you already use the get_links or wp_get_links tag in your sidebar, you’re done; the page will appear with the other pages that are listed. But if you don’t (I don’t) you’ll have to modify the sidebar.php or, in my case, the header.php file to add the link. I call the link RSS and you can see it at the top of every page.
That’s All There Is To It
Of course, if you’re like me you won’t be happy with the first version of the Page. But fixing it is easy. Just use your text editor to modify the rssfeeds.php file you created. You can reload the Page on your blog to see the results of your changes. No need to edit the Page. After all, there’s nothing in the Page, is there?
What do you think of all this? Use the Comments link to let me know. You can also use the Comments link for this post to submit questions about it; please don’t ask questions about topics not covered in this article.
For more great information about going beyond the basics with WordPress, be sure to visit the WordPress Codex and the WordPress Support Forums.













2 responses so far ↓
1 Sam // Aug 8, 2007 at 3:04 pm
Why do you have to create a new template? Why can’t you just put the codex calls in a WordPress page created using the default Page template?
2 imp // Sep 5, 2007 at 11:53 pm
is there any code to read the wordpress rss on a normal site? i want to put my blog update on other website index.
Leave a Comment