customization - Deleling wordpress posts permanently still have IDs

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

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.

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.

Share Improve this question edited Mar 30, 2019 at 19:33 Toodarday asked Mar 30, 2019 at 18:59 ToodardayToodarday 1071 silver badge3 bronze badges 1
  • 1 Possible duplicate of How to reset the post ID increment – Milo Commented Mar 30, 2019 at 19:43
Add a comment  | 

3 Answers 3

Reset to default 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?

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.

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;

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745641871a4637740.html

相关推荐

  • customization - Deleling wordpress posts permanently still have IDs

    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

    4小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信