How WP guesses which ID to use for new post?

I'm puzzled with the following. Say, post_ID of my last post is 100. Now I remove all posts from my WordPress blog and even clear all revisions and so on from database if any, so now I have nothing in my wp_posts and wp_term_relationship. I expect to get post_ID = 1 for a new post. But I get post_ID = 101. Looks like WordPress stores ID for next post somewhere, but I've already spent half a day trying to figure out: where?

Solutions

It's just an auto incrementing column in the MySQL database. MySQL is using an internal counter, it's nothing to do with WordPress.

http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

Update

To reset your post ids, run the following (substituting in your tablename):

ALTER TABLE tablename AUTO_INCREMENT = 1

Similar questions

How to programmatically GET (to know) which Sidebar (or) which Menu is being used on Different Pages?
Lets say i want to detect such thing from the "functions.php" .. to know which Sidebar (or) which Menu is being loaded on current (whatever landed) page, how can i know? Lets say i have a few pages, with: From functions.php, if: So the thing here is: How to simply do it please.
How to tell which database tables belongs to which multisite site
I have a local multisite installation I use for development with a relatively large number of sites set up. Every site has its own numbered database tables (i.e. wp_n_links, wp_n_options, wp_n_postmeta etc.) Every time I need to look at a database table in phpMyAdmin I have to look through all the wp_n_options tables to find the tables for the site...
Which url points to which file
Actually i have deployed a wordpress running website on my local environment. I want to have some general instruction that how can i know which file points to which url. Like if i entered the url mysite.com/household-insrtuments. it opens a page in the backend i searched from the text through the project i found that this opens the file name 'housi...
WordPress: different WP_Query usage: Which is correct, in which context?
I have been creating custom WordPress loops with two different approaches, both which involve creating a new instance of the WP_Query object. I typically have multiple loops on a single page. I do not understand how these two approaches differ, and which is the correct context to use each. Approach 1: http://codex.wordpress.org/Class_Reference/WP_Q...
Wordpress : How to programmatically GET (to know) which Sidebar (or) which Menu is being used on Different Pages?
Lets say i want to detect such thing from the "functions.php" .. to know which Sidebar (or) which Menu is being loaded on current (whatever landed) page, how can i know? Lets say i have a few pages, with: From functions.php, if: So the thing here is: How to simply do it please.
How to check which coupon is applied to which product in WooCommerce?
Since we can apply different coupons to each product in an order, Is there any method to know which coupon is applied to which product? I've used $order->get_used_coupons() function but it just returns the used coupon codes only. Please help with a solution. Thanks.

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.