In this tutorial, we’ll discuss a common WordPress issue: reclaiming a page permalink (also known as URL or slug) that’s already occupied by an image. We’ll walk you through the process of changing the image’s permalink, so you can name your page URL as desired.
Join +4 730 subscribers!
Understanding Why WordPress Adds The Number”-2″ to your Page URL
All permalinks have to be unique. If you try to add a permalink that already exists, WordPress will automatically add a trailing number to the slug. But, as you probably already noticed, this can also happen if you don’t have a page with the same permalink.
The most likely reason is that images (and videos, pdf:s and other media items) in your WordPress Media Library also have their own permalinks. An image’s permalink is based on the image filename minus the file extension. If you, for example, upload the image products.jpg to your WordPress Media Library, the image URL will be domain.com/products/.
If you try to create a page with a permalink that is already occupied by an image (for example products), WordPress will automatically change the page URL domain.com/products-2 without any notification. That’s not good at all. Luckily, the solution is quick and easy – if you know where to look.
Changing Image Permalinks in WordPress Media Library, Step by Step
Step 1: Access the Media Library
To get started, you need to access your WordPress Media Library:
- Log in to your WordPress dashboard.
- In the left-hand menu, hover over “Media” and click on “Library.” This will take you to your Media Library, where you can manage your images.
Step 2: Edit the Image Details
Now, locate the image for which you want to change the permalink:
- Scroll through your Media Library and find the image in question. Click on it to select it.
- Once the image is selected, you should see an “Edit more details” link. Click on this link to access the editing options for the image.
Step 3: Edit the Image Permalink
To change the image’s permalink, follow these steps:
- In the editing screen, you might not see an option to edit the permalink by default. In this case, click on the “Screen Options” button at the top-right corner of the page.
- A dropdown menu will appear. Check the “Slug” checkbox to enable the permalink editing option.
- Scroll down, and you should now see the “Slug” field. This is where you can edit the image permalink.
- Modify the Slug to your desired permalink to make the original permalink available for your page. For example, if you want to change it to “my-products” simply type “my-products” into the field.
- Once you’ve made the necessary changes, click the “Update” button to save your new permalink.
Step 4: Verify the Changes
After updating the image’s permalink, you should see a confirmation message indicating that the changes have been saved. To ensure everything is working as expected, follow these final steps:
- Navigate to the page where you want to use the permalink that was occupied by the image (in this example: “products”).
- Edit the page and change the permalink by clicking the “Edit” button to the right of the page URL below the Page Title.
Congratulations! The permalink should now be available for your page without any conflicts. Clear your browser cache and website cache to make sure that the update takes effect.
Alternative Method (If the Method Above Doesn’t Work)
If, for some reason, you cannot edit the image’s permalink as described above, you can try the following alternative method:
- Delete the image from your Media Library. Be cautious when doing this, as it will remove the image from your website entirely.
- Next, go to the page where you want to use the deleted image’s permalink.
- Edit the page and change its permalink with your desired slug.
- Save your changes and make sure that the page is published (and not just a draft).
- Finally, re-upload the deleted image. This time the tables has turned and WordPress will add the numerical suffix to the image permalink instead.
All pages and posts that contained the deleted image needs to be updated with the new image URL.
Pro tip: If you don’t want the trailing number to be added to your image’s permalink, just rename the image file name to something unique before uploading it.
That’s all for today!
WordPress provides flexibility when it comes to managing your website’s content and permalinks. By following the steps outlined in this tutorial, you can change an image’s permalink to reclaim a specific page URL. Whether you choose to edit the image’s permalink directly or use the alternative method, you’ll have the freedom to structure your site’s URLs as you see fit. This can help improve your workflow and user experience.
I hope that you enjoyed this post. Subscribe to VictorDuse.com on YouTube and join our Facebook group for more crisp content on WordPress and web design.
👉 Related post: How To Disable Automatic Image Titles In WordPress
👉 Free course: Create a website from scratch with Divi
0 Comments