How To: Easily Embed MP3 Music & Audio Content with WordPress

When we say that WordPress is a content management system we don’t just mean that it is a text publishing system. In fact, WordPress is a very versatile platform with built in capabilities to publish just about any type of content. A lot of bands, music producers, artists, podcasters, and bloggers use WordPress to share their audio content. There are wonderful plugins and themes available to publish audio content, music files, podcasts, etc. In this post we will talk about how you can easily publish your music or audio content with WordPress.

Upload and Embed an MP3 Audio file with HTML5 Player in WordPress

With HTML5, it is now very simple and easier for you to publish audio files. The problem which remains unsolved is that different browsers support different file formats and this support also changes from one platform to another. For example, if you were thinking about embeding your MP3 audio file using HTML5 there is a problem that you need to address first. Unfortunately, Firefox does not support MP3 files in HTML5. This means that you either need to provide two source files (one in MP3 and other in free ogg vorbis format) or just use ogg vorbis.

For those who don’t know, ogg vorbis is a free open format for audio encoding and streaming. It is just as good as MP3 and almost all browsers support it.

Uploading your Audio Files

First upload your audio files using the built in WordPress media uploader (The same button which you use to upload your photos). Upload your audio file, once uploaded copy the url of the file. If you are going to upload your audio file in two formats then upload the other file and copy the URL. When you are done uploading, exit media uploader and return back to the post.

Now click on the HTML editor button on your post editor and paste this code in your post:

<audio width="300" height="32" controls="controls"><source src="YourUploadedFileUrl.mp3" type="audio/mp3" /><source src="YourUploadedFileUrl.ogg" type="audio/ogg" />

Your browser does not support the audio tag.

This code is quite self-explanatory but let me explain it to you a little bit. The tag tells the browser that it needs to handle an audio file with controls.These controls are the buttons that show up in the browser to control volume and playback of audio file. line has two parameters src which tells the location of the file and the type. Notice that we have used two source files, the first one is MP3, but when a user is accessing the page with Firefox or Opera, they will fallback to the second source file. In case a user is on a platform that does not support HTML5 audio then they will see the text “your browser does not support audio tag”.

Now the problem is that writing this code each time you share an audio file is not the perfect solution for many. For those users you can create a shortcode and use it every time you upload an audio file. Using the code below, we are going to create an shortcode.

function wplift_audio_embed($atts, $content = null) {
"url" => ”
), $atts));
return ‘</pre>
<audio width="300" height="32" controls="controls" src="’.$url.’">

add_shortcode("audio", "wplift_audio_embed");


Now you can add the audio files in a post using the shortcode like this:



If you want to make this shortcode available for your widgets too then add this line of code in your theme’s functions.php file:

add_filter(‘widget_text’, ‘do_shortcode’);

Embeding Audio Files From SoundCloud into WordPress

SoundCloud is a popular audio sharing and hosting website. Many podcasters and artists are using SoundCloud to share their audio content. It supports oEmbed format which allows easy sharing by just pasting URL of the content. WordPress also supports oEmbed but currently it has a built in safelist with a few popular oEmbed content providers in it (like youtube, twitter, flickr, etc.). However, it is very easy to add an oEmbed provider into WordPress.

Add SoundCloud as oEmbed provider in your WordPress by adding just this one line of code in your theme’s functions.php file:

wp_oembed_add_provider( ‘*’, ‘’ );

Now to share content from SoundCloud all you need to do is to just paste the URL in a post and it will get embedded automatically.

Oembed HTML5 Audio Plugin for WordPress

As I mentioned earlier, WordPress community has developed several plugins to make it even easier for users to publish their music and audio content to the web. Oembed HTML5 Audio Plugin tops my list of such plugin because of its simplicity and ease of use.

With this plugin you can simply upload your file using the media uploader copy the URL and just paste the URL in the post editor. It automatically converts the URL into HTML5 audio tag and displays it with the nifty HTML5 player. However, if the site visitor’s browser does not support HTML5 or MP3 then it fallsback to flash player.

Download oEmbed HTML5 Audio Plugin »


Adding audio to WordPress is just as easy as adding a YouTube video and if you are band or artist, a podcaster or just want to sing for the world, there are some great WordPress themes designed just for you. In case you were wondering about the song that appears in the screenshots above, it can be listened here.

Noumaan Yaqoob

Noumaan Yaqoob

Noumaan is a blogger and social media expert. He loves Quora, Facebook, Wordpress, OpenSource Software and The Sims.

Related Articles


17 thoughts on “How To: Easily Embed MP3 Music & Audio Content with WordPress”

  1. Hi Noumaan, were do you paste the above code exactly to create the [audio] shortcode? Do I also need a third party plugin to make it work?

    • @d7e48d719674f335cf2ab6c51e205912:disqus your theme’s functions.php file. No you do not need a third party plugin to make it work.

  2. How to set it to autoplay? I’m using the shortcode. Also, is there any way to hide the URL of the media files from the source code view?

    • Also autoresume. Right now I can’t get the song to continue playing when I browse to other pages on the site.

  3. haha i needed this a few days ago and i find it just now. Great that you wrote this tip. I made with metaboxes (cause adding song was the main feature) and using html5 player. Your method is better for smaller need of music in the posts ^^ Still great way to do it.

  4. Your original code(long form) sources two file types(mp3, oog) for browser compatibility but your short code seems to only source one(oog in your exampe). is there a way to create a short code that sources both as in the long form code?

  5. Thanks for the HTML5 code! Can´t make the player wider by changing the width – do you know why that might be? Trying it on my site

  6. Is there a way to use this if you are pointing your domain to a free WP site? We don’t have any of the WP files nor can we modify them. I don’t have the ability to add plugins and I’ve been trying to find a way to embed a streaming player.

  7. Figured it out. Code below:

    [gigya src=”″ quality=”high” bgcolor=”black” width=”300″ height=”104″ name=”popupPlayer_V19″ align=”middle” allowScriptAccess=”always” allowFullScreen=”true” type=”application/x-shockwave-flash” pluginspage=””]

    Put your own station ID or you’ll be playing our music. :)

  8. Mr. Nouman Yaqoob,

    Good Morning,

    Today I tried to download MP3 files on my WordPress private blog & I received a an ERROR reply that WordPress does not support MP3 Audio files.

    What shall I do ?

    Please let me know.


    Tipu Sultan
    [email protected]

Comments are closed.


Create Your Own

Building beautiful WordPress websites has never been easier. Explore the visual drag & drop Theme Builder that does it all, and works on any theme. Coding skills needed: none.