1

I would like to convert the htmlentities in only my atom feed to their corresponding characters.

Using the below in my functions.php I've gotten close, but obviously the commented out line doesn't work, and the change is applied to all of my feeds.

Is there a way to do this using filters/hooks?

Thanks.

function decode_feed_entities($content) {
    return wp_kses_decode_entities($content);
}
// add_filter('do_feed_atom', 'decode_feed_entities');
add_filter('the_content_feed', 'decode_feed_entities');
add_filter('the_excerpt_rss', 'decode_feed_entities');
0

Alright there! The do_feed_atom filter should be an action hook where you add the filters:

// add our filters when we're in atom feed context
add_action('do_feed_atom', 'add_decode_feed_entities_filters', 9);    

function add_decode_feed_entities_filters() {
    add_filter('the_content_feed', 'decode_feed_entities');
    add_filter('the_excerpt_rss', 'decode_feed_entities');
}

function decode_feed_entities($content) {
    return wp_kses_decode_entities($content); 
}

Have a look in wp-includes/default-filters.php from line 162 (in wp3.4.1) for all the filters you might need to add decoding to.

Alternatively you could have used the is_feed('atom') conditional:

function decode_feed_entities( $content ) {
    if ( is_feed( 'atom' ) )
        return wp_kses_decode_entities( $content ); 
    return $content;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.