Wordpress - Attachments block slugs

Summary: Some uploaded attachments automatically get slugs I later want to use for posts. It is impossible to change them without database access and very annoying.

Hi everyone,

I am using wordpress and lately uploaded some images.

Subsequently I was trying to create a post with a certain slug but wordpress automatically added a "-2" to it, indicating that there was already a page using the slug.

I entered the slug into my browser and it redirected me to an image I had uploaded. Weird. I entered phpMyAdmin and searched the database for posts with the slug. ( SELECT * FROM wp_posts w where post_name like 'my-desired-slug'; ) In the database I found an entry of an object with post_type = "attachment". It has the desired slug assigned to it ("post_name"="my-desired-slug")

It is weird that wordpress assigned the slug to an attachment. This function is very unpractical. Now I had to edit the slug in the database since wordpress does not offer a UI section to edit attachment slugs.


  • In the admin you can go to Media, then select a image. In the detail page on the bottom right you can click "Edit more details". In the following screen below the title you can change the permalink!