Set the Length of an Excerpt in WordPress

In WordPress, there are two ways to display a summary of a post that I know about, you can use either use

 

Use this with the Quicktag

 

or

  

I like using

  

The only problem with using the_excerpt() is that there is no way to set the length of it in WordPress without modifying some code. The good news is that you can do this by simply modifying your theme’s functions.php file. You can read more about the exerpt here

So just drop this in your functions.php


function new_excerpt_length($length) {
        return 90; // change this to your liking
    }
    add_filter('excerpt_length', 'new_excerpt_length');
    function new_excerpt_mas($more) {
       global $post;
	return '' . 'Show me the money...' . '';
}
add_filter('excerpt_more', 'new_excerpt_mas');

Leave a Reply

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