Advertisement
Guest User

Untitled

a guest
Nov 21st, 2012
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1. <?php
  2. function limit_words($string, $word_limit) {
  3.  
  4.     // creates an array of words from $string (this will be our excerpt)
  5.     // explode divides the excerpt up by using a space character
  6.  
  7.     $words = explode(' ', $string);
  8.  
  9.    
  10.  
  11.     return implode(' ', array_slice($words, 0, $word_limit));
  12.  
  13. } ?>
  14.  
  15. // limit $content to 100 words.
  16.  
  17. <?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