Post slugs and images cannot have same name?

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?

1
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.

Leave a Comment