Display Message when RSS feed is empty
-
I am having a problem with the code given here for RSS feeds.
<?php // Get RSS Feed(s) include_once(ABSPATH . WPINC . '/rss.php'); $rss = fetch_rss('http://example.com/rss/feed/goes/here'); $maxitems = 5; $items = array_slice($rss->items, 0, $maxitems); ?> <ul> <?php if (empty($items)) echo '<li>No items</li>'; else foreach ( $items as $item ) : ?> <li><a href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'> <?php echo $item['title']; ?> </a></li> <?php endforeach; ?> </ul>The site I am working on pulls an RSS feed from a calendar site; when the feed is empty, I want to display a message instead. This displays the RSS feed properly when it points to a feed w/content, but it does not display the message when the feed is empty.
I would welcome *any* suggestions!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘Display Message when RSS feed is empty’ is closed to new replies.