I am trying to force all PDF links to download instead of open in a browser. I am able to easily accomplish this using the "download" attribute in an <a> tag, but that only works in Firefox & Chrome. I need to be able to have this work on iOS.
I've tried the followng .htaccess rule in the wp-content/uploads folder and that didn't work:
AddType application/octet-stream pdf
I've read a few places to use php to force the PDF download, I'm just not sure where to put it because the PDF link is dynamically generated since it's a custom post type field. Any suggestions?
As I stated in my initial statement, I have already tried to add that line to my .htaccess and it didn't work. I am thinking of using a different approach but not sure what steps to take. I would like to be able to click on the PDF Link and have it appear in a popup window PDF viewer. I have tried several different plugins but the issue that I'm coming across is the PDF url is the raw output of a custom field, which isn't registering from within other plugin shortcodes.
As I stated in my initial statement, I have already tried to add that line to my .htaccess and it didn't work.
==> Well - the code you were using and I've asked to apply has little change - could you please copy paste the code I shared and check.
The code you are using is wrong - if you just want to output the URL - you should not use the "link" attribute. I do not see there is any link attribute available.
If you output the following shortcode and if it gives you the PDF URL then it depends on the plugin you used how it parse the shortcode, its not controllable by Toolset as its third party plugin.
Thank you for your help, I was so hopeful that it would work but unfortunately none of the fixes worked. I even tried to add that code to a new .htaccess file in the uploads directory but still no luck. And even with the shortcode change, the 3rd party plugin still wouldn't recognize it as a valid URL.
Could you please share problem URL where you've added the link to force download PDF.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.