Place the following in your theme’s functions.php file.
// Excerpt Function function get_excerpt($count){ // whatever you want to append on the end of the last word $words = '...'; $permalink = get_permalink($post->ID); $excerpt = get_the_content(); $excerpt = strip_tags($excerpt); $excerpt = wp_trim_words($excerpt, $count, $words); $excerpt = $excerpt.'... <a href="'.$permalink.'">more</a>'; return $excerpt; }
or this… without the more permalink at the end:
// Excerpt Function function get_excerpt($count){ // whatever you want to append on the end of the last word $words = '...'; $excerpt = get_the_content(); $excerpt = strip_tags($excerpt); $excerpt = wp_trim_words($excerpt, $count, $words); return $excerpt; }
Paste this in your theme to display the custom excerpt.
// change the # to lengthen or shorten your excerpt echo get_excerpt(125);