Post Pic

Get rid of auto media enclosures on your WordPress blog

When you’re adding a multimedia file as such as a mp3 or flv file, WordPress automatically create a custom field named enclosure and add the media url to your rss feed. Great for podcasters, but unusefull for most bloggers. Let’s see how to get rid of it.

Just paste the following lines of codes within your functions.php file, and then, say goodby to automatic enclosures!

function delete_enclosure(){
    return '';
}
add_filter( 'get_enclosed', 'delete_enclosure' );
add_filter( 'rss_enclosure', 'delete_enclosure' );
add_filter( 'atom_enclosure', 'delete_enclosure' );

Thanks to Kny for this great recipe!

Related Posts

Related Posts

No related posts.

11 Responses

Jun 01 2009 21:03

Wow, this is what could be called very very detailed hack. I would never think of this problem, although it can be surely very useful for wp media sites.

Jun 02 2009 02:24

I’ve haven’t seen this issue before.

Jun 02 2009 08:45

Pretty decent and simple addition to the code. Figuring if what will be the effect of it for the podcasters on the other end.

Jun 03 2009 10:17

looks really interesting..!
how can i do this that when i post new article in my blog after posting i returned to post a “new post” page ?
currently i am returning to the Update post page

Jun 03 2009 13:45

@sms: I knew a method to do that, but it wasn’t recomended as it required you to edit one of WP core files.

Jun 04 2009 21:16

If you are not a Podcaster this tip is welcomed. Thanks

Jul 01 2009 13:44

Hi,

I used your code because I wanted to manually set my enclosures…But with the code as it is, iTunes does not pick up the .mp3’s that I have set enclosures thru the WP Admin (Custom Fields). Is there a modification to the code so that files that I set enclosure tags to are recognized? Thanks in advance.

Aug 21 2009 05:44

This hack SAVED my membership site. Now unpaid visitors can’t look at the RSS feed and watch the protected video tutorial files I’ve posted.

Thanks a million!!

Aug 28 2009 01:28

I get an error when I add this code. At what point in the file does it need to go in?

Thanks!!

Sep 05 2009 09:14

I’m also getting an error, any help appreciated

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required