Button with Download

Allow website visitor to click on a button to directly download a file – even a PDF – rather than first opening it in the browser.

Usually, clicking on a link (either a button or a normal text link) will cause the link to be opened in the browser, if possible. If the link is to something which can’t readily be opened within the browser, eg an Excel spreadsheet, clicking will cause the file to be downloaded instead.

Sometimes, that “click to immediately download” behaviour is what you want – sometimes it’s clear that the visitor will want to download and save the file, rather than opening it in the browser first.

This small addition allows you to choose that “download” action when adding a link to a button – even for a PDF. It is implemented via a small plugin which customises the Button block by adding a “Force Download” toggle.

Exploring the button block:-

If the button has no href, is the tag set to <button> instead of <a>?

File block

An alternative method for downloading files.

An alternative, complete, solution to the “download a document” scenario, is to use the File block. The File block already supports a “download” option, however it only works with files which are inside the WordPress media folder. To provide a complete solution, we would need to customise the File block to support files which are outside the WordPress media folder (and that may, in face, require replicating the block, since the customisation process does not readily support this modification).

Text Link

This is a text link.