Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function limit_words($string, $word_limit) {
- // creates an array of words from $string (this will be our excerpt)
- // explode divides the excerpt up by using a space character
- $words = explode(' ', $string);
- return implode(' ', array_slice($words, 0, $word_limit));
- } ?>
- // limit $content to 100 words.
- <?php $id=9; $post = get_page($id); $content = apply_filters('the_content', $post->post_content); echo limit_words($content(),100); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement