一个新闻聚合器希望RSS提要不包含指向<description>
领域所以我尝试在functions.php
删除<a href></a>
标签,但它不起作用。怎么了?如何删除标记,但保持所有文本的完整性?
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;
}