Posts Tagged 'plugin'

embed music in wordpress

By now, you may have noticed the nifty mp3 player at the top of my blog’s homepage, and perhaps you’re wondering how I managed to embed that into WordPress.

Firstly, that mp3 player is already provided by WordPress! Simply use the following code to embed it into your WordPress posts:

[audio enter-file-url-here]

Replace “enter-file-url-here” with the URL of your MP3 file.

Perhaps now you might be asking, “But I don’t have a site to host my MP3 files!” Well, there are several sites out there that will let you host files and allow hot-linking, such as Hotlink Files, FileDen and many more. But I didn’t want to waste time maintaining another separate file hosting account. So I’ve turned to WordPress itself.

“Wait a minute, my free WordPress account doesn’t allow me to upload MP3 files!”

Here’s where my nifty little “hack” comes in. WordPress blocks file uploading by extension, so you won’t be able to upload any files that end in .mp3. However, the audio player doesn’t check for this! So we can trick WordPress into accepting our MP3 file, and still play it back using the built-in audio player.

Here’s how to do it:

  1. Change the extension of your MP3 file. For example, I have a file called “MyMusic.MP3“. I can rename this to “MyMusic.JPG
  2. Now we can upload this file onto WordPress! Since the extension is now .JPG, it passes the checks, and we’re allowed to upload this into our account.
  3. Use the audio tag provided above, and replace the file URL with the one that you got after uploading your fake JPG file. It should look something like this:
  4. Save your post and test it out! Voila, we’ve managed to use the WordPress audio player to play our own MP3, and it’s stored in our WordPress account as well!

Feel free to share this nifty hack with all your friends that have WordPress accounts!