Title: I cannot shorten title posts
Last modified: August 20, 2016

---

# I cannot shorten title posts

 *  [evo252](https://wordpress.org/support/users/evo252/)
 * (@evo252)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/i-cannot-shorten-title-posts/)
 * Hello,
 * I usually use this function to shorten my titles:
 *     ```
       function the_title_shorten($len,$rep='...') {
       	$title = the_title('','',false);
       	$shortened_title = textLimit($title, $len, $rep);
       	print $shortened_title;
       }
   
       //shorten without cutting full words (Thank You Serzh 'http://us2.php.net/manual/en/function.substr.php#83585')
       function textLimit($string, $length, $replacer) {
       	if(strlen($string) > $length)
       	return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;
       	return $string;
       }
       ```
   
 * However, I have one plugin which has this line of code:
    `<a href='" . get_permalink(
   $post->ID) . "' title='". esc_attr($post->post_title) ."'>" . esc_html($post-
   >post_title) ."</a>`
 * How can I shorten the title of `esc_html($post->post_title)` ?
 * Thanks for your help !

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [evo252](https://wordpress.org/support/users/evo252/)
 * (@evo252)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/i-cannot-shorten-title-posts/#post-2117345)
 * Nobody has an idea ?? I’m blocked on this step…:/
 *  [doc4](https://wordpress.org/support/users/doc4/)
 * (@doc4)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/i-cannot-shorten-title-posts/#post-2117437)
 * evo252,
 * Wish I would have seen this sooner. Here are five ways to shorten the post title.
   Maybe this will help someone out there.
 * [http://www.doc4design.com/articles/wordpress-5ways-shorten-titles/](http://www.doc4design.com/articles/wordpress-5ways-shorten-titles/)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘I cannot shorten title posts’ is closed to new replies.

## Tags

 * [shorten](https://wordpress.org/support/topic-tag/shorten/)
 * [title](https://wordpress.org/support/topic-tag/title/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [doc4](https://wordpress.org/support/users/doc4/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/i-cannot-shorten-title-posts/#post-2117437)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
