Snippets

WordPress: Limit excerpt length

Have you ever thought of showing limited information about an article on the homepage of your blog? This limited information is called “Excerpt”. It can also be called as a “Post summary” or “Description of a post”. Here is a little snippet that will let you, in WordPress, limit excerpt length.

How to Limit excerpt length in WordPress

Simply paste the following function into functions.php file of your WordPress theme:

<?php

function limit_excerpt_length($string, $word_limit)
{
$words = explode(' ', $string);

return implode( ' ', array_slice($words, 0, $word_limit) );

}

?>

Then simply paste the following line of code in your theme, where you want to limit the excerpt length (most commonly used in index.php file)

<?php
//Simply change the number 50 to a number of your choice to limit the excerpt length
//up to the specified number
echo limit_excerpt_length(get_the_excerpt(),  '50');
?>
Your turn!

Do you know of any other ways to limit the excerpt length in WordPress? If yes, please feel free to share with us by commenting below.

45 Comments on WordPress: Limit excerpt length

  1. 1

    I don’t even know how I ended up here, but I thought this post was great. I don’t know who you are but certainly you’re going to a famous blogger if you aren’t already 😉 Cheers!

  2. 2

    I do not leave a response, however I browsed a few comments on this page WordPress: Limit excerpt length. I do have some questions for you if you don’t mind. Is it just me or does it seem like some of the comments come across as if they are written by brain dead visitors? 😛 And, if you are posting at other online sites, I’d like to keep up with you. Could you list of all of all your public sites like your Facebook page, twitter feed, or linkedin profile?

    • 3

      Hi Kaylee,
      Thanks for comment. The comments are made public only after moderation. So attempts to spam will not only get their new comments removed, but also the old ones. I will be moderating the comments even more closely to remove spam comments.

      With regards to our social sites, you may follow us by clicking on the respective Facebook / Twitter / RSS Feed icons. You can find these icons under “Follow Us” in the right sidebar towards the top of the page or in the footer. Hope this helps.

  3. 4

    Pretty good article. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be coming back and I hope you post again soon.

  4. 5

    I like this website very much, Its a very nice berth to read and find info.

  5. 6

    Great work! This is the type of information that should be shared around the internet. Shame on the seek engines for now not positioning this put up higher! Come on over and discuss with my site . Thanks =)

  6. 7

    You could certainly see your enthusiasm in the work you write. The world hopes for more passionate writers like you who aren’t afraid to say how they believe. Always go after your heart.

  7. 8

    Howdy! I know this is kinda off topic nevertheless I’d figured I’d ask. Would you be interested in trading links or maybe guest writing a blog post or vice-versa? My site discusses a lot of the same subjects as yours and I think we could greatly benefit from each other. If you are interested feel free to shoot me an email. I look forward to hearing from you! Wonderful blog by the way!

  8. 10

    I would like to consider the ability of thanking you for that professional assistance I have continually enjoyed checking out your site. I will be looking forward to the commencement of my college research and the whole preparing would never have been complete without surfing your website. If I might be of any assistance to others, I’d personally be thankful to help as a result of what I have gained from here.

  9. 11

    Is it fine to insert part of this in my weblog if I submit a reference point to this web page?

    • 12

      Hi Wanetta,
      Yes, as long as you provide a reference to our website by linking back to the original post, you can insert a part of this article. Please note that, however, graphics are custom made and they are copyrighted. In short words, you are only allowed to copy text of the articles as long as you provide linkback to the original post. Hope this helps.

  10. 13

    This really answered my problem, thank you!

  11. 14

    I’m impressed, I must say. Really rarely do I encounter a blog that’s both educative and entertaining, and let me tell you, you have hit the nail on the head. Your idea is outstanding; the issue is something that not enough people are speaking intelligently about. I am very happy that I stumbled across this in my search for something relating to this.

  12. 15

    how can i add a “…” on the last part?

    • 16

      It’s really simple. Just replace the last line in the function with the following line:
      return implode( ' ', array_slice($words, 0, $word_limit) ).'...';

  13. 17

    Can I just say what a relief to find someone who actually knows what they are talking about on the internet. You definitely know how to bring an issue to light and make it important. More people need to read this and understand this side of the story. I cant believe youre not more popular because you definitely have the gift.

  14. 18

    Hey this is a good looking blog, is wordpress? Forgive me for the foolish question but if so, what theme is? Thanks!

    • 19

      Hi Dominique,
      Yes, this is a WordPress blog. This is a custom theme that we created from scratch. If you would like to receive a quote for a WordPress theme design for your website, simply contact us by clicking on the “Contact Us” link at the top of the page.

  15. 20

    I am curious to find out what blog platform you are using? I’m having some small security problems with my latest site and I’d like to find something more safeguarded. Do you have any solutions?

    • 21

      Hi Steve,
      We are using WordPress. What is your website platform? Can you provide more details as to the specific problems you have so that I can possibly suggest you some solutions?

  16. 22

    Hello, I recently hopped to the site your site by way of StumbleUpon. Not some thing I might ordinarily examine, however i enjoyed your mind it’s unlikely that any the particular much less. Thanks for making a little something really worth studying.

  17. 23

    Just wish to say your article is as amazing. The clarity in your post is just nice and i could assume you’re an expert on this subject. Well with your permission let me to grab your RSS feed to keep updated with forthcoming post. Thanks a million and please keep up the rewarding work.

  18. 24

    I do believe all the ideas you have offered for your post. They’re really convincing and will certainly work. Still, the posts are very short for starters. Could you please prolong them a bit from next time? Thank you for the post.

  19. 25

    Is it fine to insert part of this in my weblog if I submit a reference point to this web page?

    • 26

      Hi,
      Yes, as long as you give us the credit by including a link back to the original post, you may include the text in your blog.

  20. 27

    I and my pals happened to be digesting the great advice found on the website then suddenly I got an awful feeling I had not thanked you for those strategies. Most of the people appeared to be certainly passionate to learn them and now have really been making the most of them. Thanks for getting quite accommodating and then for picking certain extraordinary things millions of individuals are really desperate to be aware of. Our own honest apologies for not expressing gratitude to sooner.

  21. 28

    I was very pleased to find this web-site.I wanted to thanks for your time for this wonderful read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you blog post.

  22. 29

    I’ve been surfing online more than three hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my opinion, if all web owners and bloggers made good content as you did, the net will be much more useful than ever before.

  23. 30

    Great article! I loved the insight and advice given. Further, your blogging style is very fun to read. If you have time kindly check out my new website and tell me what you think.

  24. 31

    You, my friend, ROCK! I found just the info I already searched all over the place and just could not find it. What an ideal site.

  25. 32

    At this time it looks like Expression Engine is the best blogging platform available right now. (from what I’ve read) Is that what you are using on your blog?

    • 33

      Hi Claudine,
      We are using WordPress. Do you need a blog to be setup on your website? If so, simply click on the “Contact Us” button at the top of the page and send us the info & I will get back to you soon.

  26. 34

    Well said. I enjoyed that very much.

  27. 35

    This is something which i dont typically do, but what the hell i loved your post so i need to say thank you. You’ve gotten a loyal reader.

  28. 36

    Whats up! I just would like to give a huge thumbs up for the nice information you’ve got here on this article. I will be coming back again to your web site for more soon

  29. 37

    Hi, I just hopped over to your web site through StumbleUpon. Not somthing I would generally browse, but I enjoyed your thoughts none the less. Thanks for creating some thing worthy of reading.

  30. 38

    Thanks for the great post. I found it really handy, keep up the good work!

  31. 39

    Nice read. This blog is awesome.

  32. 40

    Hi, have you been allowing any kind of ads in your web site? I’d love to buy a banner for a few months advertising my blog which is closely related. Let me know, or give me an email address that I can reach you at. Many thanks!

  33. 41

    I think other website owners should take this site as an model, very clean and fantastic user genial style and design .

  34. 42

    I am very pleased after reading such information post. Thanks for your wonderful tips. I like to share it with my friends who missed such wonderful tips. I like to bookmark the site to be in touch with such great posts. Keep it up.

  35. 43

    WONDERFUL Post.thanks for share..more wait .. …

  36. 44

    Remarkable! This website is visually just exactly like my own one! It is on a entirely different topic nonetheless it has more or less an identical structure and design. Excellent pick of colours!

  37. 45

    Whoa! This blog looks just like my old one! It’s on a totally different topic but it has pretty much the same layout and design. Outstanding choice of colors!

One Trackback

  1. 1

    Much Thanks!…

    Thanks for taking the time to provide us all with the info!…