Skip to content

Instantly share code, notes, and snippets.

@pavlo-bondarchuk
Created April 18, 2017 12:43
Show Gist options
  • Save pavlo-bondarchuk/7059e2d6b317ae67510391676e885cf2 to your computer and use it in GitHub Desktop.
Save pavlo-bondarchuk/7059e2d6b317ae67510391676e885cf2 to your computer and use it in GitHub Desktop.
excerpts words-symbols
function new_excerpt_length($length) {
return 10;
}
add_filter('excerpt_length', 'new_excerpt_length');
<?php the_excerpt('new_excerpt_length', 10); ?>
function trim_characters($count, $after = '...'){
$excerpt = get_the_content();
$excerpt = strip_tags($excerpt);
$excerpt = mb_substr($excerpt, 0, $count);
$excerpt = $excerpt . $after;
return $excerpt;
}
<?php echo trim_characters(200, '...'); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment