Skip to content

Instantly share code, notes, and snippets.

@JoseSoteloCohen
Created November 26, 2019 18:27
Show Gist options
  • Save JoseSoteloCohen/898cde29e799c8d1d66d2366cf43045d to your computer and use it in GitHub Desktop.
Save JoseSoteloCohen/898cde29e799c8d1d66d2366cf43045d to your computer and use it in GitHub Desktop.
// functions.php //
function custom_post_excerpt_length($post_excerpt, $post)
{
$length = 70;
$excerpt = strlen($post_excerpt) > $length ? mb_substr($post_excerpt, 0, $length - 3, "utf-8") . "..." : $post_excerpt;
return $excerpt;
}
add_filter('get_the_excerpt', 'custom_post_excerpt_length', 20, 2);
// end functions.php //
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment