Question

I searched the whole internet, including this website, but there is no written way on how to remove the enclosure url from the WordPress feed. I want to remove it because FeedBurner is adding the image url directly in the email that it is sending to subscribers. The reason doesn't really matter I guess, so simply how to remove enclosure url from the feed?

<enclosure url="https://example.com/wp-content/uploads/2017/04/whatever-image.jpg" length="5873907" type="image/jpeg"/>

the feed also has this line, which I also want to remove:

<media:content url="https://example.com/wp-content/uploads/2017/04/whatever-image.jpg" width="7360" height="4912" medium="image" type="image/jpeg"/>    

any idea on how to do this? everything I tried until now failed, including some answers on this website

Was it helpful?

Solution

You can look if your posts have any assigned enclosure meta keys, that could trigger the rss_enclosure() core function to print the <enclosure> tag. Otherwise you can try this demo plugin:

<?php
/** Plugin Name: Remove RSS Enclosure **/

add_filter( 'rss_enclosure', '__return_empty_string' );

It looks like you've a plugin that's adding the <media:content> tag, e.g. via the rss2_item hook. So check your plugins. Otherwise you can try this demo plugin to remove all extra rss2 items:

<?php
/** Plugin Name: Remove All Extra rss2 Items **/

add_action( 'rss2_head', function()
{
    remove_all_actions( 'rss2_item' );
} );

We can do similar for atom- and rss feeds.

Remember to request the feed with an url cache buster when debugging.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top