title: Limit WP excerpt to second sentence
body: <p>I'm using this function to limit my WP excerpt to a sentence instead of just cutting it off after a number of words. </p>
  
  <pre><code>add_filter('get_the_excerpt', 'end_with_sentence');
  
  function end_with_sentence($excerpt) {
    $allowed_end = array('.', '!', '?', '...');
    $exc = explode( ' ', $excerpt );
    $found = false;
    $last = '';
    while ( ! $found &amp;&amp; ! empty($exc) ) { 
      $last = array_pop($exc);
      $end = strrev( $last );
      $found = in_array( $end{0}, $allowed_end );
    }
    return (! empty($exc)) ? $excerpt : rtrim(implode(' ', $exc) . ' ' .$last);
  }
  </code></pre>
  
  <p>Works like a charm, but I would like to limit this to two sentences. Anyone have an idea how to do this?</p>