The Extra Theme comes with a Blog Feed Masonry module, which lets you display a grid of posts. As part of this, it can display an excerpt of the post content. This post describes how to change the excerpt length.
Important: Before we begin, I just want to say that this is a bit of a hacky technique and I wouldn’t really recommend doing this if you can avoid it, for reasons I’ll outline below. But it does currently let you change the excerpt length in the blog feed masonry module, so if with that said here goes…
First, here’s an example of excerpt as normally displayed by the blog feed masonry module:
The excerpt, by default is 230 characters long, or only 100 if there is a featured image.
You can change this (to 400 characters in this example) by adding the following PHP code to your site:
if ( ! function_exists( 'et_truncate_post' ) ):
function et_truncate_post( $amount, $echo = true, $post = '' ) {
return truncate_post( 400, $echo, $post );
}
endif;
As this is PHP code, you can add it to the functions.php of a child theme, or using a plugin such as Code Snippets. Please take a backup prior to adding PHP code to your site, so that you can restore the original version if necessary.
The note the following things if you are considering using this code:
1) It overrides one of Extra’s own functions, which could cause problems if Elegant Themes modify their definition of the function.
2) The function is marked as deprecated, which means it might be removed in the future, which would cause the excerpts to revert to their original length.
3) The function is currently used in some other places where excerpts are displayed and modifying it will also affect the lengths of these excerpts.
4) Currently a shorter excerpt length (100 characters) is used if a thumbnail (or map or audio player) is displayed. Modifying the function will cause a single excerpt length to be used in each case.
With all that said, here’s the effect the code has on the example excerpt from above: