Removing HTML & Content From Excerpts

Posted in: Newspaper
Post count: 4

Would you be able to suggest a method for removing any HTML content (not just the tags) from the excerpts shown?

We have been unable to understand how to accomplish this.

We have tried the following:

function excerpt_cleanse( $text ) {
$raw_excerpt = $text;
if ( '' == $text ) {
//Get Post Content.
$text = get_the_content('');
//Strip Shortcode.
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);

//Strip Header Tags & Content.
$regex = '#(<h([1-6])[^>]*>)\s?(.*)?\s?(<\/h\2>)#';
$text = preg_replace($regex,'', $text);

// Adjust Excerpt Length
$excerpt_word_count = 55;
$excerpt_length = apply_filters('excerpt_length', $excerpt_word_count);

//Adjust 'Read More' Portion
$excerpt_end = '[...]';
$excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end);

$excerpt = wp_trim_words( $text, $excerpt_length, $excerpt_more );
}
return apply_filters('wp_trim_excerpt', $excerpt, $raw_excerpt);
}

add_filter( 'get_the_excerpt', 'excerpt_cleanse', 5);

Any help, direction, or suggestion would be much appreciated.

Thanks

Post count: 22421

Hi,
The excerpts will not show html if it;s added the proper way(in text mode from the mce editor: http://screencast.com/t/MmPXfucLgmd) Please provide an example of how your excerpts are showing html and how you are implementing the html code.
Thank you!

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.