How To Set A Custom Length For Post Excerpts On WordPress

14 May 2021
4 min read

Excerpts are a default feature of WordPress Posts, and very handy in that they allow you to decide on a different preview text that users will see before clicking into your post. Excerpts are used whenever you have a post-type listing. By default, if you do not fill up the excerpt field in your post editor page, WordPress automatically takes the first 55 words of a post and uses it as the summary of the post. This is helpful as the start of your post usually has a decent summary of your content, but there are cases when you will prefer to write a different piece of content for your excerpts.

WordPress gives you the ability to do so via the excerpt field, which you can find at the right of your post editor page. If you are using an older version of WordPress (before Gutenberg) or if you are using the Classic Editor Plugin, you will find the excerpt field at the bottom of your post’s edit page (if you do not see it, turn it on via screen options at the top right of your screen).

If you have a custom excerpt filled in, WordPress will take the full length of the excerpt, even if it is more than 55 words. However, there are times where by you would want to keep the excerpt to a certain word limit so that the design of your web page is kept consistent. This is when you’ll need to set a custom length for your excerpts.

To achieve this, you simply need to insert the first piece of code below into your functions.php, and the second piece of code to wherever you need it in your template files.

Setting custom excerpts for your posts helps you to ensure you are giving them an accurate and enticing introduction with the right language. On top of that, it provides you with another opportunity to insert useful keywords that will help to boost your Search Engine Optimisation (SEO) efforts. With this handy piece of code, you’ll be able to ensure that these useful excerpts are kept looking neat and tidy too.

Unsure of where to insert this? Don’t want to break anything? Our team of WordPress developers in Singapore can accomplish this job for you safely and efficiently. We are highly experienced in WordPress and web development and are equipped in solving any issues you might be facing.

Be the first to get tips on web design, WordPress & more

Sign up for our newsletter to be in the loop.



Have queries or need some advice?