Display External RSS Feeds in our Site


Here is the code for displaying External RSS Feeds in our Worpdress Site.

<?php include_once(ABSPATH.WPINC.'/feed.php');
$rss = fetch_feed('Feed URL Goes Here');
$maxitems = $rss->get_item_quantity(4);
$rss_items = $rss->get_items(0, $maxitems);
?>
<ul style="font-family:Helvetica;font-size:15px;list-style:square;">
<?php if ($maxitems == 0) echo '<li>No items.</li>';
else
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
<li>
<a href='<?php echo $item->get_permalink(); ?>'
title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>' target="_blank">
<?php echo $item->get_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>

Keep Spreading…

Advertisements

4 thoughts on “Display External RSS Feeds in our Site

  1. A little help for a novice? I can’t get the code to work and end up with a page as below.

    $rss = fetch_feed(‘www.scotlandgaa.com/wp-feed.php’);
    $maxitems = $rss->get_item_quantity(4);
    $rss_items = $rss->get_items(0, $maxitems);
    ?>

    No items.
    ‘;
    else
    // Loop through each feed item and display each item as a hyperlink.
    foreach ( $rss_items as $item ) : ?>

    get_date(‘j F Y | g:i a’); ?>’ target=”_blank”>
    get_title(); ?>

  2. Thanks Technofreaky! Just added this to our new WP blog on our site to stream the newest forum posts (that are tied to an RSS), works great and worked first time! Thanks again!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s