WordPress Tips: Change WordPress Excerpt Length

FA Featured Article Lite
Print Post

If you blog frequently using WordPress, you probably have a landing page from which your readers can easily see an excerpt of your post. By default the post excerpt length is set to 55 characters in WordPress. You may want to increase or decrease this post length for various reasons. Personally I find 55 characters to be too short for a reader to judge if they wish to read the whole post. But I know bloggers that write great one-liners (max 20 characters) that “wet your appetite.” If you are one of them, you may want to change the excerpt length to 20! There are several ways to do this, let me share a couple.

If you’re looking for a really good web host for your blog, try Bluehost - I found the setup procedure and their control panel very easy to adapt to and their IT team is awesome!

Method 1: Using a WordPress Plugin.

There are several WordPress plugins that you can use to set the excerpt length.  I wouldn’t recommend any (unless you really hate writing code to your site!) since the 3 I tried had limited functionality or didn’t work.  Search for “excerpt plugin” on the WordPress plugin directory and you will find one.

Method 2: Edit your template’s functions.php

This requires no knowledge of php or html. It’s easy as copy and paste.

Step 1: Find the functions.php

There are two easy ways to can access your template’s function.php: WP dashboard or your cPanel. From your WordPress Dashboard, go to appearance-editor. From the right hand sidebar, choose the functions.php file.  Please note that you do not have access to the undo changes function and any saved changes are permanent!  From your cPanel, you can edit the functions.php through the file manager. In most cases you will find it in this folder path: /public_html/wp-content/themes/YOUR THEME/.  Most cPanel file managers allow you to search for the file, at least mine does!

Step 2: Edit functions.php

The next step is to copy and paste the following code to your functions.php. Where? Anywhere generally works, but try and paste it just before the end, inside the ?>. The ?> marks the end of the code in functions.php, so you want to add your code just inside that. Here’s the code. You need to copy and paste everything from // to ; and remember to edit the “200” to your desired custom excerpt length!

// Changes the excerpt length to a custom value
function custom_excerpt_length( $length ) {
return 200; // Change this to the number of characters you wish to have in your excerpt
}
add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 );

 

Step 3: Save functions.php

Save the functions.php file and you’re done.

Would you like more WordPress customization tips?  Leave a comment and let me know.

 

Comments

Leave a reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>