Change the default excerpt length in WordPress

This is another useful snippet for modifying the length of the excerpt (in amount of words).

Drop this in your theme’s functions.php and modify the length as you wish:

/*  Excerpt length
/* ------------------------------------ */
function alx_excerpt_length( $length ) {
	return 30;
add_filter( 'excerpt_length', 'alx_excerpt_length', 999 );

In this case I set the amount of words to 30.

Change the default excerpt ending in WordPress

By default, WordPress ends excerpts with “[…]” and some people do not like how that looks. So, here is how to change it to “…” or something of your own choice.

Add this to your theme’s functions.php and you are done:

/*  Excerpt ending
/* ------------------------------------ */
function alx_excerpt_more( $more ) {
	return '...';
add_filter( 'excerpt_more', 'alx_excerpt_more' );

I use & #46; instead of period signs because some web browsers tend to convert 3 period signs into something custom that may cause issues.