In this tutorial you’ll learn how to upload or link a PDF file to WordPress. If you’ve ever uploaded an image to the media library in WordPress, doing the same with a PDF is just as straightforward, so let me explain how to do that.
Upload a PDF to WordPress
Follow along with us over on our Envato Tuts+ YouTube channel:
1. Locate Your PDF File
I’m working with a demo PDF file on my system. Make sure the file size isn’t too big (your PHP hosting will likely have a limit on file upload sizes) and ideally your file’s filename shouldn’t contain any strange characters either.
In your WordPress admin go to Media > Library > Add New then use the file chooser to select your PDF, or drag and drop it into the browser:
Once uploaded you’ll be able to give the file a title, a caption, and a description (if you want). And that’s how to upload a PDF to WordPress! Now let’s see a few ways we can link to the PDF.
2. Copy and Paste the PDF File Link
Most importantly you’ll need the link to the file, so copy the whole path as you see it displayed:
You can then use that link and attach it to text in pages or posts within WordPress, by highlighting your chosen link text and adding a link like so:
Once saved, when you view the post on the front end of your website, the link will be present and when clicked will open your PDF in a browser window.
Linking From Images and Buttons
The same thing is possible with images and buttons. For example, upload an image to the WordPress Gutenberg editor, then click the link icon to add the PDF link:
3. Using the Classic WordPress Post Editor
What if you’re not using Gutenberg? The same is possible using the Classic WordPress editor too—the link button is found in the toolbar at the top of the editor:
And that’s how you link to a PDF in WordPress! But wait, there’s one more thing I want to explain..
4. How to Directly Download a PDF From a Link
Before we wrap things up, here’s an additional trick. What if you don’t want users to click your PDF link and open the PDF in another browser window? What if, instead, you’d like the PDF to directly download?
To achieve this, we need access to the HTML markup of the link itself. So in the Classic Editor switch to the text tab:
In the Gutenberg editor you can gain access to the HTML code by clicking the three dots (options) menu like so, and hitting Edit as HTML:
Then (if you’re familiar with reading HTML code) find the link in question, which should look something like this:
<a href="https://link" target="_blank" rel="noopener">Download PDF</a>
Then add the
download attribute, anywhere within the main anchor tag, like this:
<a href="https://link" target="_blank" rel="noopener" download>Download PDF</a>
That’s it! Now when someone clicks the link it will download the PDF to their system.
To learn more about how the download attribute works, here’s a useful guide:
That’s All There is to it!
That’s how you can upload a PDF to your WordPress website, and how you can link to it in a few different ways. I hope you found this tutorial useful, take a look at the following resources for more beginners’ tips!
- WordPressHow to Change the Domain Name and URL of Your WordPress SiteRachel McCollin
- WordPressHow to Change the Font Color in WordPressRachel McCollin
- WordPressHow to Change the Font Size in WordPressRachel McCollin
- WordPressHow to Change the Site Title in WordPressAdi Purdila
- WordPressWhat Are Tags in WordPress?Adi Purdila
- WordPressWhy Use WordPress?Adi Purdila
- WordPressHow to Edit the Footer in WordPressAdi Purdila
Subscribe below and we’ll send you a weekly email summary of all new Web Design tutorials. Never miss out on learning about the next big thing.Update me weekly
Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!Translate this post