Button link to download file

Hi, I’m wondering if you would know a way of forcing a download of a file, instead of just opening up the file in a browser window when clicking on the button.

On this page I’ve achieved the desired download result using the text element, but I’d prefer to use the button element if possible.
http://oliviapopsor.com/thank-you/

Thanks!

Hey,

This plugin should help you: https://wordpress.org/plugins/easy-media-download/

Thanks, I might give that a try, though my preference would be to implement html5’s easy download attribute the way I did with the text link. Seemed like there would be a way.

Hi There,

Add a class forcedownload to your button, and then add this on Theme Options > JS

jQuery( document ).ready(function($) {
	$( ".forcedownload" ).attr( "download", "" );
});

This will add a download attribute to your button element that has a class forcedownload.

But, keep in mind that not all the browsers support the download attribute, so the best way to force download is to zip your file instead.

Hope it helps,
Cheers!