If I go to Media Library and upload an image called apple-pie.jpg
And then I create a post called www.domain.com/apple-pie/ The link does NOT take me to the post. Instead the link will take me to a page displaying the media (In other words, it uses a page template instead of single.php)

So does Wordpress NOT allow images and post slugs to be the same? How do I fix this problem? Do I have to rename all of my images?

  • Well, attachments are a post type so... Oct 17, 2014 at 0:36
  • When I go to Media Library > Select an image > Click "view attachment page" > The URL is > I see the attachment page which uses a single.php template ----- However, when I go to view the post > I see a page displaying the media (instead of a post) and it uses a page template ----- So are these two different types of "attachment pages" ? Why would WordPress make TWO attachment pages? And is it best practice to name images different from post slug?
    – stadisco
    Oct 17, 2014 at 3:12
  • This should be working. I have a website where I keep image name same as page slug and it works fine because attachments are post type and its slug is attachment. So either you are doing something wrong, using plugin or theme function. Otherwise it should work. Try it with disabled plugins or preferably on a fresh install with twentyfourteen theme.
    – Robert hue
    Oct 17, 2014 at 3:58

1 Answer 1


WordPress uses the attachment filename to create the attachment post slug.

If your file was named something else, there would not be any conflicts.

If you have your post permalinks set to /%postname%/ , and you upload an image FIRST, and then create a post SECOND, then WordPress has to make a choice between the two when someone tries to access the Permalink.

To solve the issue, you would either have to change your permalink structure OR change the name of either the post or the attachment.

  • 1
    Ah I see. This makes sense now. Thanks!! If anyone is interested, as explained by Courtney, I uploaded image first which is the cause of the slug conflict. Usually I would create post first so I never encountered this issue til now.
    – stadisco
    Oct 17, 2014 at 5:29

Your Answer

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

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