Force Download PDF in WordPress

WordPress already enables you to to download PDFs and other file types simply by changing the attachment link in the media library. Like so: Attachment details for pdf file in media library But what if you want to force it to download instead of opening it up in another window? This is a quick one now so pay attention. in an .htaccess file:

https://gist.github.com/e6e2d28ab99d4964f95b

or via a php function:

https://gist.github.com/899909f2ae5478cc6257

Just a note. This is not particularly WordPress-y and can be done with all sorts of file types not exclusively .pdf’s If you want to style it like a button just give the link a class of button and use css to style accordingly.