Created
July 6, 2016 15:13
-
-
Save sarvar/dae4397756571167ecd30189cbfaa84e to your computer and use it in GitHub Desktop.
How to limit an excerpt in wordpress?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function word_count($string, $limit) { | |
$words = explode(' ', $string); | |
return implode(' ', array_slice($words, 0, $limit)); | |
} | |
************* | |
<?php echo word_count(get_the_excerpt(), '25'). '...'; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment