Created
March 30, 2017 15:07
-
-
Save clarklab/b4af33eaa4fcdb87f4a13ae98061a4c9 to your computer and use it in GitHub Desktop.
Get first X words of WordPress post
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
// toss this in your functions.php (or elsewhere) | |
function get_shorty($count = 15){ | |
global $post; | |
$str = get_the_content(); | |
$str = implode(' ', array_slice(explode(' ', $str), 0, $count)); | |
return $str.'...'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment