How To Change Media Library Slugs In WordPress

By default, media library items also have slugs, just like regular posts. First of all, we’d usually recommend disabling media library slugs as it’s unlikely you want your media library indexed by search engines in this way. You can do this easily using a simple plugin such as Disable Media Pages. You may also have this functionality in your SEO plugin, so be sure to check that first – it may be called something along the lines of “disable attachment URL’s” or similar.

Why rename?

It’s easiest to state this point with an example. You’ve uploaded an image called “contact” – it’s an image that’s going to go on a contact page that you haven’t yet created.

You go to create your “contact” page and notice that WordPress has automatically changed the URL to “contact-2” – this is because “contact” has already been taken by the image you uploaded. Annoying, right?

Fortunately, there’s an easy solution for this, but WordPress does a good job of hiding it. Many articles online about this are out of date or recommend editing the database directly – this is totally unnecessary.

Let’s go

  1. Head over to your media library and click on the image in question.

2. Click “Edit more details”.

3. Click “Screen Options” and make sure “Slug” is checked.

4. Now scroll down on the page until you find the “slug” metabox, and edit the value in here. Once this has been done, the original slug will be unlocked, and you’ll be able to use it again

To conclude

There we have it – a simple solution to an annoying WordPress problem. If you have any questions then let us know in the comments.