Customizing the Excerpt/Teaser Length in WordPress Posts

Custom Read More Length in WordPress
Written by Wamiq Ali

As previously I explained the wordpress post loop and all it’s content thus, now I decided to write a tutorial on how to control the excerpt/teaser length in wordpress post loop. There are typically two ways to control/customize the excerpt length:

  1. One From the Post Editing Section so you can customize the length of every post individually.
  2. The other method of fixing the length of every excerpt/summary or teaser through the template hard code.

Controlling the length of excerpt through the post edit section of wordpress:

You can easily do it, All you need is a code added in your post loop and then a short code to be added in the post edit area where you need to cut of the post for the homepage of your blog. Here, I am supposing that you have added your wordpress post loop at the homepage using the PHP code and you have used “the_content();” in the post loop instead of “the_excerpt();

Thus, to control the length of the summary or excerpts of the post at the homepage of your blog via post edit panel of wordpress then you need to add the_content(); instead of the_excerpt(); in the post loop code of wordpress.

For those who don’t understand that how the code of the WordPress post loop works should read this: Customizing the WordPress posts Loop using the CSS3 and PHP

I am supposing here that you have used the_content in the WordPress loop. Thus to cut off the post from the post edit panel of the WordPress and to define the custom excerpt length click the button: Insert More Tag

Read More button in wordpress

When you click the highlighted Read More button on the WordPress post edit panel then a shortcode is added in the post edit area which defines your breaking point of the post summary.

Hard Coding the excerpt/teaser length in WordPress template i-e controlling the read more length:

In this second way you need to edit the template and hard code the_excerpt(); instead of the_content(); as compared to the above method. Edit the index.php where I am supposing is your post loop and then replace the_content(); with the_excerpt(); it will automatically add the excerpt/teaser to the post and you don’t need to add read more in the post edit section.

Thus, adding the_excerpt(); in the post loop will limit the number of the words shown in the summary of the wordpress posts. By default these number of words is 55. Next time I’ll show you how to control the default length for the excerpt in wordpress using some snippet of code. Till then happy blogging 🙂

About the author

Wamiq Ali

Programmer, Blogger and an Entrepreneur trying to make this web a better place by making others learn for free.


Leave a Comment