How to link a PDF file to a category URL

If your theme has an attachment template (attachment.php) and you upload your page/post-specific media items, then you will get a page/post-specific media attachment URL.
add an image from post/page

Suppose you are adding/editing your post/page on Case Study (i.e. cs1), so your post/page URL will be (if post-name permalink structure is enabled):

http://example.com/cs1/

If you upload an image or a PDF file in this article, the image/PDF file’s URL will become:

http://example.com/cs1/cs1.pdf (see ‘edit’ below)

So you can have a nice URL that’s perfectly saying what it is and where it belongs to.

EDIT

  1. You have to have the permalink structure to post-name. You can do it from admin panel Settings ยป Permalinks.
  2. You can have a look how an attachment file can be from TwentyFifteen’s image.php. You can use image.php for that too. I’ve tested using this one and it’s completely working.
  3. When inserting the PDF file into the post/page remember to link it to the attachment page see edit#2 here in this linked answer. And I did say one thing wrong you will get an URL http://example.com/cs1/cs1 (there would be no extension in the URL) ๐Ÿ™‚

And now it’s tested. ๐Ÿ™‚