Title: recent post
Last modified: August 18, 2016

---

# recent post

 *  [hbalagh](https://wordpress.org/support/users/hbalagh/)
 * (@hbalagh)
 * [20 years, 10 months ago](https://wordpress.org/support/topic/recent-post-2/)
 * ok im using this [http://wiki.wordpress.org/Recent%20Posts](http://wiki.wordpress.org/Recent%20Posts)
   and i want to know how to make it so it will only name part of the post title(
   some of the titles are long so it looks funny when it runs off) i would like 
   it to look something like
 * Drove up the califor….
 * instead of
 * Drove up the california coast line
 * thanks guys for your help if you can tell me exactly how to do it (code to u 
   se) it would be great

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

 *  [masquerade](https://wordpress.org/support/users/masquerade/)
 * (@masquerade)
 * [20 years, 10 months ago](https://wordpress.org/support/topic/recent-post-2/#post-246770)
 * `<?php echo substr(get_the_title(), 0, [number of letters in the title]) . '...';?
   >`
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [20 years, 10 months ago](https://wordpress.org/support/topic/recent-post-2/#post-246771)
 * Change:
 * `$post_title = stripslashes($post->post_title);`
 * to this slightly more complicated block of code:
 * `$post_title = stripslashes($post->post_title);
    $title_len = strlen(stripslashes(
   $post_title)); if(21 < $title_len) { $post_title = substr(stripslashes($post_title),
   0, 20) . '...';
 * That will truncate the title and add the "..." if the title is longer than 20
   characters.
    }
 *  [Mark (podz)](https://wordpress.org/support/users/podz/)
 * (@podz)
 * [20 years, 10 months ago](https://wordpress.org/support/topic/recent-post-2/#post-246773)
 * Nick has updated the code there to a plugin:
    [http://mtdewvirus.com/code/wordpress-plugins/](http://mtdewvirus.com/code/wordpress-plugins/)
 * There is also coffee2code’s plugins one of which could help:
    [http://www.coffee2code.com/wp-plugins/](http://www.coffee2code.com/wp-plugins/)
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [20 years, 10 months ago](https://wordpress.org/support/topic/recent-post-2/#post-246887)
 * I was obviously in a hurry earlier. All those extra stripslashes() are not needed(
   and I jumped into the code with my final note):
 * `$post_title = stripslashes($post->post_title);
    $title_len = strlen($post_title);
   if(21 < $title_len) { $post_title = substr($post_title, 0, 20) . '...'; }
 * And yes, those plugins are worth a look.

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

The topic ‘recent post’ is closed to new replies.

 * 4 replies
 * 4 participants
 * Last reply from: [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * Last activity: [20 years, 10 months ago](https://wordpress.org/support/topic/recent-post-2/#post-246887)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
