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:

or via a php function:

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.