Deleted Page Still In WordPress Database

After permanent trashing/deleting a previous page with the same permalink, I still can’t make a page save its permalink without the “-2” added to the end.
How should I solve this problem?

Choosing “Quick edit” and change the slug and save will not change the permanent link too. I’m not familiar with WordPress coding or working with database inside phpmyAdmin. If I have to deal with changing SQL, please advice me in steps and easy way. Thank you in advance.

3 Answers
3

There is a function that is looking for duplicated post names: wp_unique_post_slug.

In this function are few queries, and one of them is looking for duplicated post names: SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1. If this query will return some rows then function will add suffix to post name. So you have to have some post with identical post name and post type, but with different post id than this one, which you are editing.

You can check this by editing this query and executing it in phpMyAdmin for example. This should looks like this:
SELECT post_name FROM wp_posts WHERE post_name LIKE "your_post_name%"
You need to change wp_ to your tables prefix and your_post_name to your post name (percent sign is important)

wp_unique_post_slug on trac

Leave a Comment