[wp-hackers] Re: post title excerpts/special char lengths..
    spencerp 
    spencerp1 at gmail.com
       
    Sun May 13 04:55:30 GMT 2007
    
    
  
I think I got it now.. seems to be working :D ... From this guy's blog 
here after google searching..
http://www.willoller.com/limiting-title-and-excerpt-length-with-wordpress/
MINUS Excerpt Reloaded plugin activated...  I slapped the below code in 
functions.php file:
<?php
function the_title2($before = '', $after = '', $echo = true, $length = 
false) {
         $title = get_the_title();
 
      if ( $length && is_numeric($length) ) {
             $title = substr( $title, 0, $length );
          }
        if ( strlen($title)> 0 ) {
             $title = apply_filters('the_title2', $before . $title . 
$after, $before, $after);
             if ( $echo )
                echo $title;
             else
                return $title;
          }
      }
?>
Then used this for in the index.php file:
<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent 
Link to <?php the_title(); ?>"><?php the_title2('', '', true, '30') 
?></a></h1>
Now it's cutting the post's title off at 30 characters.. whee!! Oh God 
I'm awesome.. I just can't stress it enough.. lol.. hahaha
--
spencerp
http://spencerp.net
http://www.vindictivebastard.net
    
    
More information about the wp-hackers
mailing list