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.
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!
ZeekRewards
February 17, 2012 at 7:10 pm
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?
Kaylee Carmody
February 19, 2012 at 6:48 am
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.
Robert
February 19, 2012 at 9:30 am
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.
Hoyt
March 6, 2012 at 5:55 am
I like this website very much, Its a very nice berth to read and find info.
March 8, 2012 at 8:47 pm
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 =)
Laticia Cuny
March 9, 2012 at 2:01 am
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.
March 12, 2012 at 12:12 pm
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!
March 14, 2012 at 11:09 pm
Can you get back to me with your website and blog URL? That way, we can discuss things.
Robert
March 17, 2012 at 6:41 am
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.
Lala Schappert
March 19, 2012 at 1:25 pm
Is it fine to insert part of this in my weblog if I submit a reference point to this web page?
Wanetta
March 20, 2012 at 5:54 am
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.
Robert
March 21, 2012 at 11:36 am
This really answered my problem, thank you!
Nan
March 22, 2012 at 5:32 am
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.
Keira Hoylton
March 23, 2012 at 3:14 am
how can i add a “…” on the last part?
jlapitan
March 24, 2012 at 7:13 pm
It’s really simple. Just replace the last line in the function with the following line:
return implode( ' ', array_slice($words, 0, $word_limit) ).'...';Robert
March 24, 2012 at 11:45 pm
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.
Brian Torrella
March 25, 2012 at 9:12 am
Hey this is a good looking blog, is wordpress? Forgive me for the foolish question but if so, what theme is? Thanks!
March 27, 2012 at 1:57 am
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.
Robert
March 27, 2012 at 3:14 am
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?
Steve Arend
March 28, 2012 at 10:25 am
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?
Robert
March 31, 2012 at 2:14 am
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.
best over the counter wrinkle cream
March 28, 2012 at 12:26 pm
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.
Hot Carl
March 28, 2012 at 6:48 pm
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.
Hot Carl
March 29, 2012 at 5:58 pm
Is it fine to insert part of this in my weblog if I submit a reference point to this web page?
March 29, 2012 at 10:42 pm
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.
Robert
March 31, 2012 at 2:17 am
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.
March 30, 2012 at 5:01 am
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.
March 30, 2012 at 7:13 pm
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.
Hot Carl
March 30, 2012 at 7:59 pm
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.
March 31, 2012 at 5:42 am
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.
Marchelle Feigel
March 31, 2012 at 6:47 am
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?
March 31, 2012 at 9:41 am
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.
Robert
March 31, 2012 at 2:04 pm
Well said. I enjoyed that very much.
Heather Janey
March 31, 2012 at 6:35 pm
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.
mesothelioma lawyer
March 31, 2012 at 6:41 pm
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
March 31, 2012 at 9:24 pm
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.
Elvis
March 31, 2012 at 10:00 pm
Thanks for the great post. I found it really handy, keep up the good work!
Banqueting halls in London
April 1, 2012 at 1:22 am
Nice read. This blog is awesome.
Anjelica Barksdale
April 3, 2012 at 12:40 am
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!
April 3, 2012 at 5:51 am
I think other website owners should take this site as an model, very clean and fantastic user genial style and design .
Margery Grappe
April 3, 2012 at 10:31 am
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.
Raleigh Web Development
April 3, 2012 at 10:41 am
WONDERFUL Post.thanks for share..more wait .. …
April 4, 2012 at 9:31 pm
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!
Joie Threet
April 12, 2012 at 11:07 am
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!
Tyesha Speiden
April 16, 2012 at 12:59 am