Back WordPress

Changing WordPress Excerpt Length and Custom More Text

WRITTEN BY ON 19 Jul 2011

Most of the WordPress blogger uses excerpt to display a short summary of articles. This snippet able to let your control the length of excerpt, and make a custom more text after the excerpt. It uses add_filter with excerpt_length and excerpt_more. This snippet only work with excerpt generated by WordPress, not working with the optional excerpt field in the backend.


Open functions.php in your template folder, and append this into that file.

function custom_excerpt_length( $length ) {
	return 20;
add_filter( 'excerpt_length', 'custom_excerpt_length');

function custom_excerpt_more( $more ) {
	return 'Read story';
add_filter( 'excerpt_more', 'custom_excerpt_more' );
Join the discussion

Comments will be moderated and rel="nofollow" will be added to all links. You can wrap your coding with [code][/code] to make use of built-in syntax highlighter.