title: SimplePie: filter by item value and number of items
body: <p>Basically I want to filter only items from various feeds that have a certain category using an of statement, and show only 6 items. I can do successfully either but not both at the same time. I'm trying to first filter the items depending on category and then limit the number of those items to six, or whatever is set. The code is as follows (which does the opposite, I don't understand how to do the other way around). Hope someone helps. Thanks a lot!</p>
  
  <pre><code>&lt;?php 
   require_once('simplepie131.inc');
  
      $feed = new SimplePie();
  
      $feed-&gt;set_feed_url(array(
  
      'http://site1.com/rss',
      'http://site2.com/rss',
      'http://site3.com/rss',
      ));
  
  
      $feed-&gt;enable_cache(true);
      $feed-&gt;set_cache_location('cache');
      $feed-&gt;set_cache_duration(1800);
  
      $feed-&gt;init();
  
      $feed-&gt;handle_content_type();
  
  
  include('header.php'); 
  ?&gt;
  
  
  &lt;h1&gt;Title&lt;/h1&gt;
  
  &lt;?php 
  
  foreach ($feed-&gt;get_items(0, 6) as $item): 
  
  
   ?&gt;
  
      &lt;?php
       if(    $item-&gt;get_category()-&gt;get_label() == 'category1' 
          or  $item-&gt;get_category()-&gt;get_label() == 'category2' 
          or  $item-&gt;get_category()-&gt;get_label() == 'category4' 
          ):
      ?&gt;
  
  &lt;div&gt;   
      &lt;h2&gt;&lt;a href="&lt;?php echo $item-&gt;get_permalink();  ?&gt;"&gt;&lt;?php echo $item-&gt;get_title();?&gt;&lt;/a&gt;&lt;/h2&gt;
  
  
      &lt;img src="&lt;?php echo $item-&gt;get_description(); ?&gt;" /&gt;
  
      &lt;img src="&lt;?php echo $item-&gt;get_feed()-&gt;get_image_url(); ?&gt;" /&gt;
  
      &lt;?php 
      echo $item-&gt;get_feed()-&gt;get_title();
      echo $item-&gt;get_category()-&gt;get_label();
      echo $item-&gt;get_date('d.m.Y | H:i');
      ?&gt;
  &lt;/div&gt; &lt;!-- end div --&gt; 
  
  
      &lt;?php endif;?&gt;
  
  
  
  
  &lt;?php endforeach; ?&gt;
  </code></pre>