Have you seen blogs where different types of RSS feeds are displayed on pages and blog posts? If you have installed WordPress out of the box, the only way that you can add RSS feeds to your theme is usually via the “RSS” feed widget but then it is only displayed on a widget ready area on your theme. If you would like to add any “RSS” feed to your theme, there’s a couple of ways this can be accomplished.
- Install a plugin
- Create a “template” file with custom RSS code
- Edit or create a new widget ready area on your theme
Install the RSS in Page plugin
This is by far the easiest way to add custom “RSS” feeds on your blog posts and pages.
Once you have installed the plugin, you can add the below code to any page or blog post to display the “RSS” feed.
[rssinpage rssfeed=’http://yourfeed.com’ rssdescription=’yes’ rssdateformat=’j F Y’ rsscss=’rssclass’ rssitems=’15’]
Replace “http://yourfeed.com” with the RSS feed you would like to add and change “rssitems” to the number of items you would like to display.
Create an RSS template file
In my previous post about WordPress, I explained how you can create your own custom template files. Using that method, create a template and add the following code to that template page.
include_once(ABSPATH.WPINC.’/rss.php’); // path to include script
$feed = fetch_rss(‘http://www.yourfeed.com/’);
$items = array_slice($feed->items, 0, 25); // specify first and last item
Replace “http://yourfeed.com” with the address of your feed.
Widget ready areas
If you would like to add more widget areas to your theme where you can drag and drop the RSS widget from the dashboard directly onto the widget area, have a look at this page on widgetizing your theme – Widgetizing Themes.
The methods explained above is an excellent way that you can basically add any RSS feed to your WordPress posts or Pages ranging from YouTube RSS feeds, blog feeds, Twitter Statuses, etc.
If you are interested in any other WordPress tutorials or website design packages, contact us.