Basic SimplePie Usage

You'll need a of copy SimplePie for the include right at the top here.

    $feed = new SimplePie();

    if ($feed->error): ?>
        <p><?php echo $feed->error; ?></p>
    <?php endif; ?>

    <?php foreach ($feed->get_items() as $item): ?>
    	<div class="chunk">
    		<h4 style="background:url(<?php $feed = $item->get_feed(); echo $feed->get_favicon(); ?>) no-repeat; text-indent: 25px; margin: 0 0 10px;"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h4>
    		<p class="footnote">Source: <a href="<?php $feed = $item->get_feed(); echo $feed->get_permalink(); ?>"><?php $feed = $item->get_feed(); echo $feed->get_title(); ?></a> | <?php echo $item->get_date('j M Y | g:i a T'); ?></p>
    <?php endforeach; 
Deploy a static site in one minute
Build and deploy a CMS-enabled site with Gatsby in just a few clicks. It's free.


  1. User Avatar
    Permalink to comment#

    I was playing around with this but it only loads the tweets the first time, then no further updates. I tried the workaround that SimplePie recommended, commenting out the lines of code, but it rendered the entire file useless.

    Were you able to get this to work?

  2. User Avatar
    Permalink to comment#

    Now SimplePie uses an autoloader.php instead of

  3. User Avatar
    Aalaap Ghag
    Permalink to comment#

    Any idea why $feed is being redefined inside the loop?

Leave a Comment

Posting Code!

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.