Advertisement
alchymyth

excerpts for pages

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