When someone visits our permalink, we need it to go directly to the media PDF, rather than showing a page with the preview which is clickable. Is this possible?

2 Answers 2


It sounds like you're embedding the PDF directly into the page using the media library function.

Instead, you can visit the media library directly, copy the permalink of the file you'd like to link to, and use the copied permalink as the hyperlink around for text or the image.

It's manual, but solves your problem without any bloat or custom fixes.

  • Not trying to embed, we just want outsite.com/msa to go directly to download a PDF. We used a redirect plugin in the end.
    – HippoDuck
    Commented Jan 19, 2022 at 11:27

Without seeing your code I will make some assumptions. I assume that when you were trying this you were using the_permalink() as your href value inside the loop something like this:

<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>

However, as you noted this takes to you the preview of the attachment. Instead you need to echo wp_get_attachment_url() to get the URL of the file like below.

<a href="<?php echo wp_get_attachment_url(); ?>"><?php the_title(); ?></a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.