Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function improved_trim_excerpt($text) {
- global $post;
- if ( '' == $text ) {
- $text = get_the_content('');
- $text = apply_filters('the_content', $text);
- $text = str_replace('\]\]\>', ']]>', $text);
- $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
- $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
- $text = strip_tags($text, '<p>, <strong>, <a>, <br>');
- //$excerpt_length = 55;
- //re-introduce the possibility to change excerpt length with filter
- $excerpt_length = apply_filters('excerpt_length', 55);
- //re-introduce the possibility to use excerpt more filter
- $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
- $words = explode(' ', $text, $excerpt_length + 1);
- if (count($words)> $excerpt_length) {
- array_pop($words);
- array_push($words, $excerpt_more); //edit
- $text = implode(' ', $words);
- }
- }
- return $text;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement