Loading...

Here’s a couple of useful functions which allow you to customize the appearance of the excerpts of your posts in the category and post lists. The standard output is […] and something like eighty odd words.

Using the first segment of code you are able to replace the brackets and dots with a link like the one below, or change it to something better for you. The second piece allows you to control the number of words in the excerpt.

// Replaces the excerpt "more" text by a link

add_filter('excerpt_more', 'new_excerpt_more');

function new_excerpt_more($more) {
       global $post;
	return '<a class="moretag" href="'. get_permalink($post->ID) . '"> Read More...</a>';
}
// Change number of words displayed in the excerpt

add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

function custom_excerpt_length( $length ) {
	return 27;
}

Simply copy and paste this code into the functions.php file and it will do the rest. And you can obviously edit the code further to make it do precisely what you require.

Latest Posts

Portfolio

Contact

Fill in the form below to send us a message. Your details will not be used for promotional purposes or passed on to any third parties.

 

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close