Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bahiirwa/d773a50708fbd25a3b5f98823a2a296b to your computer and use it in GitHub Desktop.
Save bahiirwa/d773a50708fbd25a3b5f98823a2a296b to your computer and use it in GitHub Desktop.
Using function to limit the characters returned in WordPress
I don't quite get your question but his worth a try, if I am understanding you. Add this function to your functions.php or a related file
<pre>
function get_excerpt2($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, ""));
return $excerpt;
}
"<?php echo <?php echo get_excerpt2(520); ?>...Read More"
</pre>
And then return this code in your template. You can change the html bits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment