On a WordPress project, I wanted to display the full post on the blog archive unless a manual excerpt had been created for the post (in which case I wanted to use the manual excerpt).
I’m a big fan of the Genesis framework and in the Genesis theme settings under Content Archives there is a Display option where you can choose between:
- Entry content
- Entry excerpt

Genesis Settings Screenshot
The problem here is when you choose Entry content
, the content is used regardless of whether or not the post has a manual excerpt. In my case, I wanted a manual excerpt to override displaying the Entry content.
Solution
Step 1: Remove the Default Excerpt
remove_filter( 'get_the_excerpt', 'wp_trim_excerpt' );
Step 2: Add Our Own Excerpt Filter
add_filter( 'get_the_excerpt', function( $excerpt ) {
if ( $excerpt ) {
// If an excerpt already exists (e.g. manual excerpt) display it.
return $excerpt;
}
// Use the full post content as the excerpt.
return get_the_content();
});
Full Solution
This is the code I place in my home.php
template because I only wanted this behavior on the Posts Page (a.k.a. blog page). You could place this code somewhere else (e.g. a mu-plugins file or functions.php
, see functions.php vs plugin vs mu-plugin for WordPress for more information on these choices).
/**
* Use the full post content as the excerpt
* unless a manual excerpt exists.
*/
remove_filter( 'get_the_excerpt', 'wp_trim_excerpt' );
add_filter( 'get_the_excerpt', function( $excerpt ) {
if ( $excerpt ) {
// If a excerpt already exists (e.g. manual excerpt) display it.
return $excerpt;
}
return get_the_content();
});
Leave a Reply