How to Upload or Link a PDF to WordPress

How to Upload or Link a PDF to WordPress

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:

Media  Library  Add New

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:

PDF link

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:

adding link in editor

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:

Linking From Images

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:

Using the Classic WordPress Post 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:

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:

Edit as HTML

Then (if you’re familiar with reading HTML code) find the link in question, which should look something like this:

Then add the download attribute, anywhere within the main anchor tag, like this:

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:

  • Quick Tip: Using the HTML5 Download Attribute

    HTML5

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!

  • WordPress
    How to Change the Domain Name and URL of Your WordPress Site
    Rachel McCollin
  • WordPress
    How to Change the Font Color in WordPress
    Rachel McCollin
  • WordPress
    How to Change the Font Size in WordPress
    Rachel McCollin
  • WordPress
    How to Change the Site Title in WordPress
    Adi Purdila
  • WordPress
    What Are Tags in WordPress?
    Adi Purdila
  • WordPress
    Why Use WordPress?
    Adi Purdila
  • WordPress
    How to Edit the Footer in WordPress
    Adi Purdila

Go to Source
Author: Adi Purdila

Next PostRead more articles