• I’d like the RSS feed of another site to run in the sidebar of my website, Evil Beet Gossip. The WP Codex provides example code for how to do this.

    <h2><?php _e('Recent news from Some-Other Blog:'); ?></h2>
    <?php // Get RSS Feed(s)
    include_once(ABSPATH . WPINC . '/feed.php');
    
    // Get a SimplePie feed object from the specified feed source.
    $rss = fetch_feed('https://example.com/rss/feed/goes/here');
    
    // Figure out how many total items there are, but limit it to 5.
    $maxitems = $rss->get_item_quantity(5); 
    
    // Build an array of all the items, starting with element 0 (first element).
    $rss_items = $rss->get_items(0, $maxitems);
    ?>
    
    <ul>
        <?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'); ?>'>
            <?php echo $item->get_title(); ?></a>
        </li>
        <?php endforeach; ?>
    </ul>

    The site whose RSS I want to import is here and the RSS feed for it is here. The code provided in the codex works when I use, say, CNN’s RSS feed, but it doesn’t work when I use the feed I want to use. It just stops loading when the PHP code starts running.

    Is there something wrong or incompatible with this feed? Is there a change I need to make in the PHP code?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Running RSS Feed in Sidebar’ is closed to new replies.