Embed RSS feed into your WordPress page content

RSS feeds are common in sidebars. Fuelled by widgets and looking much the same from site to site. Some designers create widgetized areas for their clients so they can put RSS feeds in the main content column. There is a simpler way, using a handy shortcode.

RSS Feed shortcode

function tcb_rssfeed_shortcode($atts){
  include_once(ABSPATH.WPINC.'/rss.php');
  $default = array(
    'feed'    => 'http://www.tcbarrett.com/feed',
    'entries' => 3,
  );
  extract( shortcode_atts($default, $atts) );
  if( function_exists('wp_rss') )
     return wp_rss($feed, $entries);
  return '';
}
add_shortcode('rssfeed', 'tcb_rssfeed_shortcode');

You can now easily insert your own feed:

[[rssfeed]]

Here is an example of my own site’s rss feed:

[rssfeed]

How to extend the idea

There are various ways one could expand on this. For example, adding optional pre and post text would allow a wrapping div and title to be added.

Published by

TCBarrett

Open Source Architect (Web Geek)

One thought on “Embed RSS feed into your WordPress page content”

Comments are closed.