Welcome! This is an advanced WordPress tutorial on how to customize WordPress feeds. If you’re not quite sure what feeds are or need to know more about them before reading this more advanced tutorial on WordPress feeds, please read my first tutorial regarding WordPress feeds called Understanding WordPress Feeds. I will not explain the basics of feeds in this tutorial, so if you have any questions about what they are or how they work, you should read my first tutorial about WordPress feeds.
What You Will Learn
In this tutorial, I will show you how to change the look and feel of your WordPress RSS feeds. If you have yet to check out what your RSS feed page looks like, go to it now and have a look. You should be able to view your RSS feeds by adding one of the following URL endings to your WordPress blog’s main URL such as yoursite.com/blog/feed or try these endings until one works:
Ideally, the first URL ending above should work, but might not on some of your blogs because it may not be set up properly. If it doesn’t work, one if the ones below it should. Try each until you find one that works for you. If the first one doesn’t work, refer to my first tutorial I wrote about feeds mentioned above to find out how to fix it.
Also in this tutorial we will cover the following WordPress topics:
- Feed template tags
- wp_meta function of WordPress
- Feed customization plug-ins
- Building a custom feed template
Since this is an advanced WordPress tutorial, there are several things about WordPress and coding that you need to know before you will be able to understand everything in the tutorial. Here is a quick list of things you should already know:
- Feeds – if you don’t have an understanding of what they are, read “Understanding WordPress Feeds” before continuing with this tutorial.
- PHP – You should have at least some prior experience developing with PHP.
- HTML – You will need to know basic HTML.
- WordPress – You should have at least intermediate experience setting up and editing templates in WordPress.
- XML – Because we are dealing with feeds and feeds are XML based, it would help to know a little XML, although not mandatory.
Feed Template Tags
There are feed template tags you can use to display the URL of any of the WordPress feeds available. They include ones for RSS, RSS2, Atom, and RDF feeds. Here is an example of each:
Using them is quite simply. Wherever you place it will display the URL to the corresponding feed so using the previous example would produce:
You would normally use it in conjunction with a link tag if developing a custom theme. If you are customizing an existing theme however, you will be most likely dealing with the wp_meta WordPress function as we will explain below.
the wp_meta function is usually found in the sidebar.php file as it is part of the sidebar widget for most themes. It is also where the feeds are called from, so you will need to familiarize yourself with this function to work with feeds. The wp_meta function is located in the wp_includes directory in the file named general-template.php. If you look at the general-template.php file, you will see the wp_meta function is nothing more than a call to a hook using the do_action function and looks like this:
The wp_meta call to action is used to add links to the meta section of the sidebar. So that is how the links get there for the feeds. You can use this method if you want to, but it is probably easier to go around it in make your own links using the feed template tags described earlier, especially if you want to provide custom styles in your links or make them unique in any way. Basically, building your own is easier than editing the functions necessary with the wp_meta call to action.
Custom feeds in WordPress can be a real challenge for beginners and pros alike because unless you are very familiar with the way feed readers work and the process they use to present the XML data used in the feeds, customizing them might seem impossible at first. This is why I would recommend using a plug-in if you want to add custom feeds to your WordPress blog. There are a few good plug-ins out there that can handle the task for you quite efficiently. Here are some you could use:
- Feed Wrangler – will help you for cases where you want to bypass your regular feeds, change your feed URLs or even add or remove ads from feeds. Feed Wrangler can be downloaded from: http://wordpress.org/extend/plugins/feed-wrangler/
- Feed Template Customize – is another custom feed plug-in that allows you a bit more freedom as far as actual custom styles go. Download this plug-in from: http://wordpress.org/extend/plugins/feed-template-customize/
- Better Feed – is another feed plug-in you can download that is great for adding things to your feeds. One thing about the default feed templates is that they are not easy to add links, comments, etc. to, so this plug-in may be the solution for you if you just want to add few things to your feeds.
Custom Feeds Without a Plug-in
Okay, I warned you that this wasn’t easy, but if you got this far in the tutorial and still want to do completely custom feeds on your own, I do have a solution for you that isn’t too difficult. My ultimate solution when I had to do this for a client was to create a custom template, give it a URL resembling a feed URL and publish it as a page from the WordPress dashboard. Let me explain. Here is how I did it:
First, make a custom page template with XML feeds in mind. You can use this one, copy it and make changes as you desire or start from scratch if you know enough about it to do so. This is the easiest way to replace default feeds I could find though, so here you go:
There, the bulk of the work is done for you. Here are the steps you need to take next to make this work:
- Make the necessary changes to the above code as you see fit. Things you might want to change could include the template name, title, link and description. Then, give it a file name that resembles the template name so you can recognize it later.
- Upload the custom feed template to your active WordPress theme. If you are using twentyeleven, upload it to that folder or if not, upload to the folder that has your theme’s name.
- Go to your WordPress dashboard and click the link in the left column to add a new page.
- You can give the page a title if you want, but do not do anything else except choose the template name you created in the right column towards the bottom of the page then click “publish” to save the page and make it live.
- Also you can use the permalink option at the top of the page to give the page it’s own special URL if you so choose, but this is optional.
- Now view the page, copy the URL and give it to all your friends and tell them that it is your new custom feed page! You are done.
If you did all the steps correctly, you should have a feed page that looks something like this:
There are some further actions that you may want to look into after using the custom template method described above. For example you may want to consider disabling the default Feeds that you intend to replace. If this is something you would like to try, here is the code you would add to your functions.php file to disable each, but don’t do so unless you are sure you want to disable them and only exclude the ones you are replacing:
Just put the above code somewhere convenient in the functions.php and it will disable all feeds or use just the lines you want that correspond with the feed you are replacing. In our case we replace only the RSS 2.0 feed, so we used the third line above in green text.
Another interesting option when it comes to feeds is integrating FeedBurner or other online feed services with your WordPress site instead of only using the default feed options. To do this, read the page in the WordPress codex regarding using FeedBurner with WordPress at: http://codex.wordpress.org/Using_FeedBurner
In this tutorial you should have learned some of the more advanced topics regarding WordPress Feeds. If it was too much for you, start by reading my first tutorial on feeds mentioned above. While customizing templates for feeds is a complex matter, I showed you a viable solution that you can use for substituting default feed actions in WordPress. If you want to actually customize the default theme templates, you can find the files to do so in the wp-includes directory, but I feel my method described at the end of this tutorial is adequate for most people’s needs. Should you feel otherwise, feel free to tackle feeds the hard way, but it won’t be nearly as simple as the solution above. Also, you will probably gain a huge headache learning everything you need to know to do it in that fashion. If someone is an expert on XML feeds and feed readers, then they can surely do it, but the rest of us should probably either use a plug-in or the solution above. Good luck with your WordPress feeds and don’t forget to have fun doing it! If you are not having fun, what are you getting paid for?