This is a revision of an Old one and going over new options for achieving the same results. How to set up a file to download and not open in the browser. If you want to manually code this into a theme – Visit the old – Make a File Download Link Part #1
Those 3 options above will help you get download links set up to manage your Downloads.
If you really want to do it with code –
Visit the post – Make a File Download Link Part #1