On wordpress home page many sites are showing the post description or we can say the excerpt. For UI purpose some time we need to control the excerpt character limit.  I already written about this in following article. But some people need the more advanced excerpt. Following code snippet will be helpful to you show the limit excerpt length by characters in wordpress.

First open your functions.php file and put following code in that file.

Solution code is Hidden! It's Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.

Use this function if you’re planning on using it more than once with a different amount of characters.

Call the function plus the amount of characters –

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php echo get_excerpt(125); ?>

Following is my old article link.

Limit excerpt length by characters in wordpress

Limit excerpt length by characters in wordpress

Written by Purab

My name is Purab, Here is my Personal Blog: wpapi.com. I contributor of many wordpress plugins and Drupal Modules. I am core developer of Drupal. Connect to on LinkedIn or Follow @purab on Twitter or Follow me on Google+ or Write Mail to purabdk@gmail.com or Chat with me on Skype : purabdk

This article has 6 comments

  1. Chuck Reply

    This code works brilliantly but, is there a way to preserve a space between p tags? If the excerpt is automatically generated from the post and there is a line break, what you wind up with is no space between the end of one sentence and the start of another. How do you strip_tags but add a space where p’s used to be?

    Something like this.Does not look right.

  2. Alicia St Rose Reply

    I shared this on Twitter and G+ and I can’t see the code.
    To be honest, it’s disappointing to have to share something I don’t know even works!

    I’m sure I can find this somewhere else.


Leave a Comment

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