RogerJH Posted June 17, 2010 Share Posted June 17, 2010 I would like to display an RSS feed in a content element here: http://thepimmgroup.org/ In the box where it says "Coming soon" When I add the PHP code to the index.php file, I'm getting errors with whichever method I have tried. e.g., With the Simple Feed List WP plugin, I embed <?php if (function_exists('simple_feed_list')) : ?> <h2>TEST FEED</h2> <ul> <?php simple_feed_list('feed://feeds2.feedburner.com/filehippo','5',''); ?></ul> <?php endif; ?> And get an error: Warning: fopen(feed://feeds2.feedburner.com/filehippo) [function.fopen]: failed to open stream: No such file or directory in/home1/thepimmg/public_html/wp-content/plugins/simple-feed-list/simple-feed-list.php on line 41 And it just goes on to the next line with another error, then another, apparently caught in a loop. If I try this code: <?php include_once(ABSPATH.WPINC.'/rss.php'); // path to include script $feed = fetch_rss('feed://feeds2.feedburner.com/filehippo'); // specify feed url $items = array_slice($feed->items, 0, 7); // specify first and last item ?> <?php if (!empty($items)) : ?> <?php foreach ($items as $item) : ?> <h2><a href="<?php echo $item['link']; ?>"><?php echo $item['title']; ?></a></h2> <p><?php echo $item['description']; ?></p> <?php endforeach; ?> <?php endif; ?> I get this error: Warning: array_slice() expects parameter 1 to be array, null given in /home1/thepimmg/public_html/wp-content/themes/ecogreen/index.php on line 79 BTW Line 79 reads: $items = array_slice($feed->items, 0, 7); With this code: <?php include_once(ABSPATH.WPINC.'/rss.php'); // path to include script $num_items = 10; $url = feed://news.google.com/news?q=biodiversity&output=rss; $rss = @fetch_rss( $url ); $items = array_slice($rss->items, 0, $num_items); echo "<br />n<h4>" . $rss->channel['title'] . "</h4>"; echo "<dl class="thepost">n"; foreach ($items as $item) { $href = $item['link']; $title = $item['title']; echo "<dt><a href=$href>$title</a></dt>n"; } echo "</dl>"; ?> The site breaks and I get an error: Parse error: syntax error, unexpected ':' in /home1/thepimmg/public_html/wp-content/themes/ecogreen/index.php on line 79. Line 79 is $url = feed://news.google.com/news?q=biodiversity&output=rss; (which is a valid feed). So I'm kinda stuck. Can any of you PHP wizards please point me in the right direction? Thank you!!! Quote Link to comment Share on other sites More sharing options...
RogerJH Posted June 17, 2010 Author Share Posted June 17, 2010 Well it's not solved but I found a temporary fix using a Javascript application. http://feed2js.org I hope to implement a PHP solution if I can get your help! Quote Link to comment Share on other sites More sharing options...
ciber Posted June 17, 2010 Share Posted June 17, 2010 Personally I think feed2js is a better option as it does not slow down your servers execution time - when using feeds I always end up having to cache the files, as to increase loading time. But then again, it may not suite what your doing. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.