Force download PDF file from URL in wordpress

rowmoin picture rowmoin · Mar 21, 2017 · Viewed 10.3k times · Source

In WordPress, how do I create a link to a file such as "file.pdf" and force it to download instead of opening the file in the browser?

Answer

rowmoin picture rowmoin · Mar 21, 2017

Just add download attribute ( download) on your a tags and leave it empty as a default file name of a file.

Example: < a href="http://wordpress.org/download/download.pdf" target="_blank" download>WordPress Download PDF</a>