Categories
Genesis Tutorials

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:

Download Folder

How The Link is Added

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.

Related Solutions

2 replies on “Add Download Link To Audio Player in WordPress”

Leave a Reply

Your email address will not be published. Required fields are marked *