Skip to content

Instantly share code, notes, and snippets.

@CEscorcio
Created June 17, 2013 16:52
Show Gist options
  • Save CEscorcio/5798361 to your computer and use it in GitHub Desktop.
Save CEscorcio/5798361 to your computer and use it in GitHub Desktop.
Limit excerpt and change read more text
functions.php
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 = '<p>'.$excerpt.'... </br><a href="'.$permalink.'">Read more more</a></p>';
return $excerpt;
}
template.php
<?php echo get_excerpt(325); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment