Simple WordPress Title Limit Function

Put this code in to your function.php (Note: Fix php tag!)-

< ?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;
}
}
? >

Write this code where you limit your title–

< ?php the_title2(”, ”, true, ‘30′) ? >

Leave a Reply

Your email address will not be published. Required fields are marked *