Change excerpt length in WordPress

Some themes have hard coded (built in without options) lengths for excerpts on the home page, search results, and archive pages. Without the ability to change this easily, you’re left with a theme that may not suit your needs. The two choices that I find to be the easiest are to edit your functions.php file to include a filter or to install a plugin to handle this for you. Either way is fine, though you may use one over the other based on your experience with WordPress internals.

Plugin

This is by far the easiest method, though not the most customizable. You’re bound by whatever the plugin allows you to change, and there’s no guarantee that the plugin will work with whatever version of WordPress is installed on your host.

  1. Search for the Advanced Excerpt plugin.
  2. Go to its settings page and choose your options.
  3. The first setting is the excerpt length (based on words or characters).
  4. The rest allows you to change what is being filtered, what text you want to show when the user can read more, and other options.

Functions.php

If you’re more comfortable with coding, changing WordPress internals, and have general access to the source code of your host’s WordPress installation, then this is the best option for you.

  1. Using a FTP client (I use FileZilla), connect to your host’s WordPress installation.
  2. Download and edit the functions.php file.
  3. Add the following to the file, where “20” is the length of the excerpt. Change that to whatever you want to use.
  4. Save and upload the file back to your WordPress installation.

One thing to keep in mind is that the above advice is editing the theme directly and is not the best approach. If you update the theme from the author, all changes that you made will be lost. Instead, you should look into creating a child theme and performing the above steps on that.

Posted in Web

Leave a Reply

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