Snippet: Default excerpt when no excerpt was added

Add following snippet to “functions.php”


add_filter( 'the_excerpt', 'default_excerpt_when_empty', 10, 1 );
function default_excerpt_when_empty( $excerpt ){
    if(empty($excerpt)) {
    	return "This post does not have any excerpt";
    return $excerpt;

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>