One news aggregator wants to have RSS feed without any links into the <description>
field. So I try to use this code in functions.php
to remove <a href></a>
tags, but it doesn’t work. What’s wrong? How can I remove the tags but keep intact all the text?
add_filter('the_content', 'my_custom_feed');
function my_custom_feed( $content ){
global $post;
if ( ! is_feed() )
return $content;
// Remove all shortcodes
$content = strip_shortcodes( $post->post_content );
$content = strip_tags( $content );
// Remove all html tags, except these
$my_allowed_tags = array(
'p' => array(),
'strong' => array(),
'em' => array(),
'img' => array( 'src' => array(), 'width' => array(), 'height' => array() ),
);
$content = wp_kses( $content, $my_allowed_tags );
// Balance tags
$content = balanceTags( $content, true );
return $content;
}