Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Rewrite the excerpt settings
- function get_excerpt($text, $post_id) {
- $post_content = get_post($post_id);
- $text = $post_content->post_content;
- $text = apply_filters('the_content', $text);
- $text = str_replace('\]\]\>', ']]>', $text);
- $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
- $text = strip_tags($text, '<p><a><img><ul><li><strong><br>');
- $excerpt_length = 50;
- $words = explode(' ', $text, $excerpt_length + 1);
- if (count($words)> $excerpt_length) {
- array_pop($words);
- array_push($words, '...');
- $text = implode(' ', $words);
- $text = force_balance_tags( $text );
- }
- return $text;
- }
- add_shortcode('full-post-excerpt', 'get_excerpt');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement