How to Limit the Number of Posts on SimplePie
SimplePie is a code library written purely in PHP, a scripting language used for Web development. It is primarily targeted toward managing RSS and Atom feeds. RSS and Atom feeds are Web feed formats used to publish work updated frequently. SimplePie is a free open-source software that is easy to use due to its thorough documentation and the availability of reference lists, tutorials and screenshots. These attributes make it a very friendly program to modify. Limiting the number of posts for a cleaner interface is a simple modification that a user can make.
Instructions
-
-
1
Use the set_item_limit() method. To set the limit to five, write:
$feed->set_item_limit(5);
If this method does not work, skip to the next step.
-
2
Open the editable multifeeds.php demo page.
-
-
3
Inside the $feeds array, list all the feeds that you would like to appear. To add yoursitehere.com to the feed, write:
$feeds = array(
'http://yoursitehere.com'
); -
4
Set the number of items for SimplePie to grab per feed.To limit the feed to five items, write:
$items_per_feed = 5;
-
5
Make sure that the program will not try to grab more items than in the feed by setting the maximum to $items_per_feed. For example:
for ($x = 0; $x < $feed->get_item_quantity($items_per_feed); $x++)
{
$first_items[] = $feed->get_item($x);
}
-
1