title: Wordpress auto trim the_content questions
body: <p>I have a this function.</p>
  
  <pre><code>function trim_the_content( $the_contents = '', $read_more_tag = '...READ MORE', $perma_link_to = '', $all_words = 100 ) {
      // make the list of allowed tags
      $allowed_tags = array( 'a', 'abbr', 'b', 'blockquote', 'b', 'cite', 'code', 'div', 'em', 'fon', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'label', 'i', 'p', 'pre', 'span', 'strong', 'title', 'ul', 'ol', 'li', 'object', 'embed', 'param' );
      if( $the_contents != '' &amp;&amp; $all_words &gt; 0 ) {
          // process allowed tags
          $allowed_tags = '&lt;' . implode( '&gt;&lt;', $allowed_tags ) . '&gt;';
          $the_contents = str_replace( ' ]]&gt;', ' ]]&gt;', $the_contents );
          $the_contents = strip_tags( $the_contents, $allowed_tags );
          // exclude HTML from counting words
          if( $all_words &gt; count( preg_split( '/[\s]+/', strip_tags( $the_contents ), -1 ) ) ) return $the_contents;
          // count all
          $all_chunks = preg_split( '/([\s]+)/', $the_contents, -1, PREG_SPLIT_DELIM_CAPTURE );
          $the_contents = '';
          $count_words = 0;
          $enclosed_by_tag = false;
          foreach( $all_chunks as $chunk ) {
              // is tag opened?
              if( 0 &lt; preg_match( '/&lt;[^&gt;]*$/s', $chunk ) ) $enclosed_by_tag = true;
              elseif( 0 &lt; preg_match( '/&gt;[^&lt;]*$/s', $chunk ) ) $enclosed_by_tag = false; 
              if( !$enclosed_by_tag &amp;&amp; '' != trim( $chunk ) &amp;&amp; substr( $chunk, -1, 1 ) != '&gt;' ) $count_words ++;
              $the_contents .= $chunk;
              if( $count_words &gt;= $all_words &amp;&amp; !$enclosed_by_tag ) break;
          }
                  // note the class named 'more-link'. style it on your own
          $the_contents = $the_contents . '' . $READ_MORE_TAG . '';
          // native WordPress check for unclosed tags
          $the_contents = force_balance_tags( $the_contents );
      }
      return $the_contents;
  }
  </code></pre>
  
  <p>When I call the function in my index the "Read More..." is missing.</p>
  
  <pre><code>&lt;?php
  // here's the point where we are about to display Post excerpt
  $perma_link = get_permalink( $post-&gt;ID ); // current Post permalink
  $content = get_the_content(); // save entire content in variable
  $content = apply_filters( 'the_content', $content ); // WP bug fix
  $content = str_replace( ']]&gt;', ']]&gt;', $content ); // ...as well
  echo trim_the_content( $content, __( "READ MORE", "sofa_memento" ), $perma_link, 100 );
  ?&gt;
  </code></pre>
  
  <p>Does anyone see my problem?</p>