Here is how to setup a custom length excerpt without cutting off the last word.

First, Add the following snippet to your functions.php file:


function get_excerpt($count){
  $permalink = get_permalink($post->ID);
  $excerpt = get_the_content();
  $excerpt = strip_tags($excerpt);
  $excerpt = substr($excerpt, 0, $count);
  $excerpt = substr($excerpt, 0, strripos($excerpt, " "));
  $excerpt = $excerpt.'... more';
  return $excerpt;
}

Next, add the following code where you want the excerpt to show up:




Change your excerpt length from 125 to whatever length you want it to be.

Leave a Reply

Get in Touch

Please fill out the form below and we will get back to you ASAP