• Posted: 2012-05-04
  • Author: Josh McDonald
  • Tags:

Truncate Post Title

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
<?php
function customTitle($limit) {
	$title = get_the_title($post->ID);
	$title = substr($title, 0, $limit) . '...';
	echo $title;
}
?>

Instructions:

Paste this function in your functions.php file, and whenever you’re in need of truncating a title, call: . Where (50) is the number of Characters it allows before truncating!


Related links:
onestepcreative.com
Share this snippet

If you like this snippet, share it with friends!