Add Download Link To Audio Player in WordPress

This post contains a download folder with templates for use with the native WordPress audio player.

The templates also include a button which enables your readers to download a copy of the audio file to their local computer.

download-link

The method of adding this link uses pure PHP code with a div class to add a button or style the link anyway you like.

Video Demo

Here’s the folder which includes the templates with code for adding the link to download your audio files:

The download button is added using the following line of code in the single-podcast.php file:

printf( '<a href="%s" class="download-link button download">' . __( 'Download' ) . '</a>', $media_link );

The above code only works with the single-podcast.php file and uses the file URL you add to the custom field value field on any Edit Post screen.

audio-link

After you upload your audio file to the WordPress media library, simply grab the full URL and paste it into the value field with the audio_link custom field key as seen above.

The code in the single-podcast.php file pulls the file URL from the custom field and adds it to a link which is styled as a download button. Simple as that.

No need to modify the WordPress core MediaElement code or use any other method to add the link.


Comments

2 responses to “Add Download Link To Audio Player in WordPress”

  1. […] Add Download Link To Audio Player in WordPress […]

  2. […] Add Download Link To Audio Player in WordPress […]

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.