I wasted several hours today on a crazy problem where I was using pretty permalinks in WordPress 4.0. The website is a car dealership, and I needed to create a page with the title as “86”.
I noticed that the slug came up as 86-2, and after a while, I cleared the trash (not that there was an 86 page there), and tried to change it to 86. It didn’t change. I gave it up as a lost cause.
Then the customer demanded that there not be a -2 on the url.
Next came scanning through the wp_posts table in the database with phpMyAdmin, looking for a conflict. I couldn’t find one.
More searching on Google for changing permalinks, slugs, duplicates, and then (after much tearing out of hair and frustration, optimising the database etc etc etc) I found the answer.
WordPress doesn’t like slugs that are purely numbers. They are reserved.
I tested creating a brand new page with title 99. The slug became 99-2.
The only successful way I found to fix this issue was installing yet another plugin – Permalink Editor. In the page editor, after activating the plugin, underneath the permalink there is a “customize” button. I entered “86”, I saved, I viewed. Yay! Issue resolved.
Edited to add: I have since found another plugin, more recently updated and ten times more popular that also serves this function, so I’ve replaced Permalink Editor in favour of a plugin that has more enduring commitment: Custom Permalinks. Same story – doesn’t work in Quick Edit, so don’t try there!
If you are getting a -2 and it’s not because the slug you want ends in a number, check your page/post trash, and check that you don’t have a category or tag with the same slug.
Thanks to you Melissa for re-posting this – although I’d like to add my experience here since they closed the topic on wordpress forums and you stay focused solutions to the whole nothing-but-numbers-slug issue.
For everyone out there who found either of these posts when looking for a solution:
This error is NOT simply limited simply to posts/pages/products with ONLY numbers in their name – in fact – it can occur in ANY post including those that DONT have a number in their name (That is, of course, until -2 is appended to the slug).
Changing permalink structure doesn’t help (which I find a really dodgy, dangerous way of triggering htaccess to be rewritten by the wordpress core to include mod rewrite, but anyway).
Trashing and permanently deleting the offending original post doesn’t help.
I’m on WP 4.2.9 & WC 2.4.9 so clearly core updates have not resolved the underlying issue in the last 4 years.
I find it unacceptable that users should install a 2 year old third-party plugin to solve an as-yet unresolved woo / wordpress issue?
Surely whatever code they are using to make it trigger the slug rewrite should highlight to WP/WC coders the solution to this?
It may help in finding a solution to mention that originally these -2 slugged products were created using a CSV product importer.
Anyone else had this when the post ISN’T all numbers?
Thanks for your reply. It is absolutely nutty isn’t it? I’m just thankful that this solution has continued to work for the websites I needed this for.
Did you check for other terms with the same name? E.g. Categories, tags, product categories, media files? Those have slugs too and can interfere.
Thank you SO much for posting this. I was pulling my hair out!
I had same issue but immediately got it out of my way with this plugin https://wordpress.org/plugins/permalink-manager It works fine, however after a while I went back to this bug in hope to find some other solution without the plugin. To make the long story short, I did not find anything out there regarding this really annoying WordPress bug. Shame that you wrote this article 2 years ago and WP hasn’t done anything to fix this issue.
On the bright side besides our links work fine now this plugin https://wordpress.org/plugins/custom-permalinks what I like the most is that it even removes the totally unnessesary slash / at the very end of the URL :)
Thanks Melissa
Open your phpMyAdmin > choose your wordpress database > klik SQL then type this:
SELECT ID, post_title, post_name, post_type
FROM `wp_posts`
WHERE post_name LIKE ‘findthis%’
ORDER BY post_name
*) replace “wp_posts” with your own table name, and “findthis%” with text you want to find.
Hi Day, I am new to WordPress and having issues changing my slug which has -2 after it and the trash isn’t showing. I tried following your helpful steps but could you explain what you mean by “your own table name”.
Many thanks!
Hi Tokunbo,
In your WordPress database, the default name for the posts table is wp_posts. However you can change the prefix to something else other than wp_. Look in your wp-config.php to check what your prefix is, or it will be pretty clear if you open phpMyAdmin. If this is too technical, you probably shouldn’t be opening phpMy Admin.
Many thanks Melissa, i have added http://www.visit2srilanka.com/2020 it came up with 2020-2 . I tried so many ways but thank you so much, after installing the Permalink Editor , it worked !!!
Pradeep from WEBS R US