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.
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:
(see ‘edit’ below)http://example.com/cs1/cs1.pdf
So you can have a nice URL that’s perfectly saying what it is and where it belongs to.
EDIT
- You have to have the permalink structure to
post-name
. You can do it from admin panel Settings ยป Permalinks. - You can have a look how an attachment file can be from TwentyFifteen’s
image.php
. You can useimage.php
for that too. I’ve tested using this one and it’s completely working. - 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. ๐