title: Custom function to limit excerpt length is returning post title as part of excerpt (WP)
body: <p>I added the following to functions.php:</p>
  
  <pre><code>function excerpt($limit) {
  global $id;
    $excerpt = explode(' ', get_the_excerpt(), $limit);
    if (count($excerpt)&gt;=$limit) {
      array_pop($excerpt);
      $excerpt = implode(" ",$excerpt).'... &lt;p class="readmore"&gt;&lt;a href="'. get_permalink($id) . '" title="' . the_title_attribute( array('echo' =&gt; 0, 'before' =&gt; 'Permalink to: ', 'after' =&gt; '')) . the_title() . '"&gt;Read More &amp;#187;&lt;/a&gt;&lt;/p&gt;';
    } else {
  $excerpt = implode(" ",$excerpt).'... &lt;p class="readmore"&gt;&lt;a href="'. get_permalink($id) . '" title="' . the_title_attribute( array('echo' =&gt; 0, 'before' =&gt; 'Permalink to: ', 'after' =&gt; '')) . the_title() . '"&gt;Read More &amp;#187;&lt;/a&gt;&lt;/p&gt;';
    } 
    $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
    return $excerpt;
  }
  </code></pre>
  
  <p>and for some reason it's returning the post title as part of the excerpt (Post title comes first, then excerpt without a space between title &amp; excerpt -- sample here: <a href="http://autisticadvocacy.uniongraphics.org/category/news/" rel="nofollow">http://autisticadvocacy.uniongraphics.org/category/news/</a>). Can anybody tell me what I am doing wrong?</p>