Title: PHP Character Limit
Last modified: August 19, 2016

---

# PHP Character Limit

 *  Resolved [ajcke](https://wordpress.org/support/users/emerinea/)
 * (@emerinea)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/php-character-limit/)
 * I have posts in the a category of “news” posting to my sidebar.php. I would like
   to limit the number of characters by replacing <?php the_content(); ?> with something
   that will limit the number of characters and number of posts. I’ve tried some
   plugins but they limit the number of characters for my posts on my main page.
   Also some of the plugins conflict with the image I want displayed in each post.
 * Here’s the webpage: [http://blog.hardinnorthern.org](http://blog.hardinnorthern.org)
 * Any suggestions?
 * Thanks,
    Andy

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

 *  Thread Starter [ajcke](https://wordpress.org/support/users/emerinea/)
 * (@emerinea)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/php-character-limit/#post-1159262)
 * I figured out how to limit the number of posts. I’m just not sure about limiting
   the number of characters.
 *  [Ashish Kumar (Ashfame)](https://wordpress.org/support/users/ashfame/)
 * (@ashfame)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/php-character-limit/#post-1159642)
 * Yes I am also looking for the same thing. Can WP do that on its own or I have
   to strip out some content manually with php code?
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/php-character-limit/#post-1159643)
 * Limiting the number of posts could be as simple as using the **showposts** argument
   with [template tag](http://codex.wordpress.org/Template_Tags), [query_posts()](http://codex.wordpress.org/Template_Tags/query_posts).
 * In a [post loop](http://codex.wordpress.org/The_Loop)
 *     ```
       <?php
       echo 'truncated post content to 50 chars ' . substr($post->content,0,50);
       ?>
       ```
   
 *  [Ashish Kumar (Ashfame)](https://wordpress.org/support/users/ashfame/)
 * (@ashfame)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/php-character-limit/#post-1159645)
 * Now I have placed my custom function in the functions.php but it seems that the
   file is not being loaded. I am working on localhost. Any idea?
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/php-character-limit/#post-1159646)
 * ashfame – please start another topic with your question.

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

The topic ‘PHP Character Limit’ is closed to new replies.

## Tags

 * [characters](https://wordpress.org/support/topic-tag/characters/)
 * [limit](https://wordpress.org/support/topic-tag/limit/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 8 months ago](https://wordpress.org/support/topic/php-character-limit/#post-1159646)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
