Creating a Feed Aggregator Page for WordPress with Simplepie

I recently had to work for a client project where i had to pull in rss feeds from various urls and show them in a single page on a wordpress installation,

I first tried to get a free plugin that would do the job. I tried several, but customizing those plugins turned out to be a headache. So i decided to write my own!

Creating an aggregator in wordpress is fairly easy if you have some experience with simplepie – an excellent feed parser script written in php. To make matters easier, simplepie ┬ácomes bundled with WordPress core.

You will need a list of feeds which you want to show in your aggregator page.

Copy paste the following code to any blank php file. Save and upload this file to your active WordPress theme folder.

<span style="line-height: 1.714285714; font-size: 1rem;">"",</span>
<div class="site-content" id="primary">
<div id="content" role="main">

"Graphic Design Blog" =&gt; "",
"Dexigner" =&gt; "",
"Smashing Magazine" =&gt;"",
"PSD Tuts" =&gt;"",
"You The Designer" =&gt;"",
"Web World ST" =&gt;"",
"Design Instruct" =&gt; "",
"Web Design Ledger" =&gt;"",
"One Xtra Pixel" =&gt;"",
"Hongkiat" =&gt;"",
"Rebuilding The Web" =&gt; "",

foreach ( $feed_sources as $index =&gt; $source ) {

$feed = fetch_feed( $source );

echo "
<div class="feed-block">
echo "
<h2 class="source-header">" . $index . "</h2>

foreach( $feed-&gt;get_items(0,5) as $item ){

$itemlink = esc_url( $item-&gt;get_permalink() );

$itemlink = str_replace( array("http://", "www."), array(""), $itemlink );

echo "
	<li><a href="/out/go.php?id=&quot;">" . esc_html( $item-&gt;get_title() ) . "</a></li>



echo "




<!-- #content -->

<!-- #primary -->

<!--?php get_sidebar( 'front' ); ?-->
<!--?php get_footer(); ?-->

Next go to your wordpress admin panel. Create a new page and select ‘Aggregator Layout’ as page theme. Publish.

Depending on your theme style you may need to modify the structure of this page. You will also need to apply your own css rules.

fetch_feed() is a native WordPress function used to get a feed. This function will open appropriate ports on target location and retrieve the feed. You just need to pass a feed url to it.

The feed array contains list of all feeds which you want to download and parse. If you are parsing a single feed then you can do away with this array and simply pass the target feed’s url to the fetch_feed() function once – you will also need to remove the foreach loop in this case.

This is just a very basic aggregator. I am working on adding a complete admin panel for managing and updating the feeds. Stay tuned to this page.

You can see the demo here:

VN:F [1.9.12_1141]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.12_1141]
Rating: 0 (from 0 votes)
This entry was posted in General. Bookmark the permalink. Both comments and trackbacks are currently closed.