The function the_excerpt()
is only a echo of the function get_the_excerpt()
:
function the_excerpt() {
echo apply_filters('the_excerpt', get_the_excerpt());
}
If you like a fall back for no input the excerpt meta box, then create a text from the content – get_the_content()
. You can use the core function wp_trim_words()
for set the counter for words and easy to set a text from all content.
A example:
$excerpt = get_the_content();
$excerpt = esc_attr( strip_tags( stripslashes( $excerpt ) ) );
$excerpt = wp_trim_words( $excerpt, $num_words = 55, $more = NULL );