Jump to content

RogerJH

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Posts posted by RogerJH

  1. 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!!!

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.