How to Stop WordPress from Enclosing MP3s in Posts

Occasionally there may be a time when you really don’t want to publish all the MP3s of a post in your RSS feed. Unfortunately WordPress will not allow you to remove an MP3 it’s linked to. To be more accurate WordPress will always link to all available media files every time you press *Save.*

This becomes a huge issue when you are recording a podcast and linking to various MP3s you might have played during the course of a show. However with the addition of one letter to one line on one page of your WordPress installation you too can be enclosure free… and by free, I mean you will from this point on never have WordPress enclosing files even if you want them. You may of course manually enclose files, but this may problematic for some people.

# Find the folder in your WordPress Installation named *wp-includes*
# open the file in that folder named *functions.php*
# Scroll down to line 766 which starts preg_match_all and edit the bit that should have *http* and make it now read *httpp*
# Save the file and upload to your server.

*What did I just do?* Well, in effect you have told WordPress only to enclose files which start with httpp://www.yaddayadda…… and since no link can ever be on a server that starts httpp it will never include a file.

*It’s ugly, but it works.*

p(note). This hack has been tested with WordPress 1.5.x Please be cautious of modifying your WordPress code and always have a backup in the wings. I take no responsibility for broken sites.


3 responses to “How to Stop WordPress from Enclosing MP3s in Posts”

  1. Here’s an interesting addition to this hack that I discovered. There was a thread about all of this at the WordPress Support forum, and someone there detailed the hack you’re talking about. I put the hack in place, and then started a little experimenting.

    You can still add an enclosure from within the WordPress admin panel after doing this hack (which I think is really useful). Just use Custom Fields. All you need to do is turn on advanced controls, and add “enclosure” as the Key and the URI of the file you want to podcast.

    Here’s the thread (i’m “scruffy”):

  2. woops…

    you put the URI as the Value :)

  3. Yeah, WordPress is really rough with enclosures. But better than a hack, here's a plugin: