title: WordPress multisite , shows all sites but only want to display last 2
body: <p>I need to display the last 2 posts of a network of sites. Currently I'm retrieving all latest posts for all sites but only want to display 2 of them.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>&lt;?php
    $items = return_latest_posts();
    global $wpdb;
    $table_search = $wpdb-&gt;prefix . "searchinfo";
    $query = "SELECT * FROM `$table_search`";
    $wpdb-&gt;show_errors();
    $results = $wpdb-&gt;get_results($query);
  
    foreach ($results as $site){
      $item = return_latest_posts_single_site($site-&gt;username,$site-&gt;password,$site-&gt;database,$site-&gt;host,$site-&gt;db_prefix);
    ?&gt;
  
  &lt;li&gt;
    &lt;h4&gt;&lt;?php echo $site-&gt;sitename; ?&gt;&lt;/h4&gt;
  
    &lt;?php foreach($item as $res){  ?&gt;
      &lt;p class="date"&gt;&lt;?php echo $res-&gt;post_date ?&gt;&lt;/p&gt;
      &lt;h4&gt;&lt;a href="&lt;?php echo $res-&gt;guid; ?&gt;" target='_blank'&gt;&lt;?php echo $res-&gt;post_title ?&gt;&lt;/a&gt;&lt;/h4&gt;
    &lt;?php } ?&gt;
  
    &lt;hr /&gt;
  
  &lt;/li&gt;
  
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>How am I able to only show the last 2 posts of all sites together?</p>
  
  <p>Thanks in advance!</p>