-1

Example: Right now I have 100 posts. If I add a new post it will have ID 101. If I delete all the current 100 posts the new post will still have ID 101 when it should have 1 or 0.

How can I delete ALL records of posts.

1
3

Even if you find a way to reset the post and pretend it didn't happen, you shouldn't.

WordPress uses a relational database structure. In short, a bunch of different tables in the database point to and rely on each other. The ID value of each row, such as the post ID for posts, is particularly important for linking different rows in different tables.

For instance, the "posts" table stores basic information about each post, including the post ID. The "post_meta" table stores additional information about posts, linked to that post ID. The "comments" table stores comments, also cross-referenced to those post IDs. The list goes on and on.

Even within that same table ("posts"), other entries such as revisions refer back to the original post ID!

So as you can see, it's a complicated web of relationships. If WordPress was designed to go back and scrub all of these links when you trash a post, then I suppose it would work. It would still be confusing and a bad user experience, like how @Loren Rosen mentioned, which is one reason WordPress doesn't do it that way.

But the fact is, WordPress will not do all that for you when you trash a post. Some of the data is, I believe, removed when the post is permanently deleted. But a lot of those other records would be not just broken, but wrong.

So in summary, it's not a good idea. The post IDs are usually hidden from users, unless you aren't using permalinks, so what exactly are you trying to accomplish?

0

Each post gets a ID that's unique over all time (with regard to that site). Otherwise, it would cause lots of confusion. For example, imagine if someone had bookmarked post 1 (by id, not by, say, slug),then viewed it later, and found, not something that said it had been deleted, an entirely different post.

0

You need to truncate the table to reset the ID's then post id will start from first.

TRUNCATE TABLE wp_posts;
TRUNCATE TABLE wp_post_meta;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.