Guest User

Untitled

a guest
Jul 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. function string_limit_words($string, $word_limit)
  2. {
  3. $words = explode(' ', $string, ($word_limit + 1));
  4. if(count($words) > $word_limit)
  5. array_pop($words);
  6. return implode(' ', $words);
  7. }
  8.  
  9. <?php if ( $woo_options['woo_post_content_home'] == "true" ) the_content(); else $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,38); ?>
  10.  
  11. function string_limit_words($string, $word_limit)
  12. {
  13. $words = explode(' ', $string, ($word_limit + 1));
  14. if(count($words) > $word_limit)
  15. array_pop($words);
  16. return implode(' ', $words) . '...';
  17. }
  18.  
  19. function string_limit_words($string, $word_limit)
  20. {
  21. $words = explode(' ', $string, ($word_limit + 1));
  22. if(count($words) > $word_limit)
  23. {
  24. array_pop($words);
  25. $words[] = '[...]';
  26. }
  27. return implode(' ', $words);
  28. }
  29.  
  30. echo string_limit_words($excerpt,38) . " ...";
  31.  
  32. function string_limit_words($string, $word_limit)
  33. {
  34. $ellipses = '';
  35. $words = explode(' ', $string, ($word_limit + 1));
  36. if(count($words) > $word_limit) {
  37. array_pop($words);
  38. $ellipses = ' ...';
  39. }
  40. $newString = implode(' ', $words) + $ellipses;
  41. return $newString
  42. }
Add Comment
Please, Sign In to add comment