1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Modding FirstRSS plugin for wordpress to display maximum # of items

Discussion in 'PHP & Perl' started by srhcom, Jun 22, 2009.

  1. srhcom

    srhcom Junior Member

    Joined:
    May 12, 2009
    Messages:
    101
    Likes Received:
    52
    I am trying to edit FirstRSS to limit output of RSS items to 10. Here is the code that outputs all items in the feed. I am not a programmer so any help is appreciated! I pulled this off of the firstrss comment page.
    Code:
    [B]
    
                        // Item title, description, & link
                        foreach($rss->items as $item) {
                            $title = $item[title];
                            $link = htmlentities($item[link]);
    
                            if ($title != '') $disp .= "\t<a href='$link'>$title</a><br />\n";
                        }
                    }
    
            [/B]
    Here is the snippet I want to put in to limit output to 10 items. It isn't working though, all items are still displayed.

    Code:
    // Item title, description, & link
    $i=0;
    foreach($rss->items as $item) {
    if($i < 10) {
    $title = $item[title];
    $link = htmlentities($item[link]);
    if ($title != '') $disp .= "\t$title\n";
    }
    $i++;
    }
    
     
    Last edited: Jun 22, 2009