Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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');
share|improve this question
add comment

1 Answer

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;
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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