Advertisement
alchymyth

Untitled

Apr 17th, 2011
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. instead of:
  2. <?php the_content(); ?>
  3. try and use (partly adapted from 'wp_trim_excerpt()' ):
  4. <?php
  5. $length = 120; //set length in words
  6. $text = get_the_content('');
  7.     $text = apply_filters('the_content', $text);
  8.     $text = str_replace(']]>', ']]&gt;', $text);
  9. $text = strip_shortcodes( $text );
  10. $text = strip_tags($text);
  11. $words = explode(' ', $text, $length+1 );
  12.   if (count($words)> $length) {
  13.     array_pop($words);
  14.     $text = implode(' ', $words);
  15.   } else {
  16.     $text = implode(' ', $words);
  17.   }
  18. $text = apply_filter('the_content', $text);
  19.  
  20. echo $text;
  21. echo '<a href="' . get_permalink($post->ID) . '">continue reading...</a>';
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement