I've been searching high and low trying to figure out how to create download links for audio files uploaded to a post.

I know how to display the audio url directly into the theme template, but when it's clicked, it just starts to stream the audio right in the browser.

I need a way to prompt the file to download once clicked.

Looking for more of a snippet for the functions.php file than a plugin.


Some people like to stream audio in the browser, others like to download. Each of them is able set up the browser to choose between downloading or streaming different MIME types to get what they need.

On the other hand you can force download of certain MIME type files using PHP header() function.

See How can I force a file download in the WordPress backend? for starting point.

| improve this answer | |
  • Well the thing is I alreay have a audio player streaming the files, the function I'm looking for is so a user can download the audio file their listening to by simply clicking a link. – Chozen Mar 2 '13 at 19:12
  • Please supply your question with more information about clicking as it will be useful for other users and will be searchable also. What do you have already tried? We need some code to think on. – Max Yudin Mar 2 '13 at 20:39

Add this to your .htaccess

# Force mp3 Download instead of display
<FilesMatch "\.mp3$">
ForceType applicaton/octet-stream
Header set Content-Disposition attachment
# End Force mp3 Download instead of display
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.