-1

Let's say I've created few categories with ID 2,3,4. Then I've deleted these categories. And when I'm creating new category after that, it has ID 5, not 2, as it may seems. So, where is WP store start value from which categories ID count starts?

Ustym Rado
  • 13
  • 3
  • 2
    The database stores that value, WP has little to do with it. Wordpress just inserts a new record into the database, and the database creates a new id for that record while doing so. And if the actual purpose of your question is that you want to “reset” that number after deleting categories, so that you don’t have “holes” in the sequence - then please go properly research why that would not be a good idea to begin with. – CBroe Jun 26 '17 at 10:44
  • I don't want to reset it, I need to get it. – Ustym Rado Jun 26 '17 at 10:58
  • 1
    What for, and when? You can easily “get” it _after_ you created a new category. If you tried to get it before, that can easily lead to race conditions, so that would not be a good approach to begin with. – CBroe Jun 26 '17 at 11:04
  • Oh, c'mon, why don't you just tell me where is that number stores if you know that? – Ustym Rado Jun 26 '17 at 11:10
  • 1
    It is stored directly in the database table. https://stackoverflow.com/questions/6761403/how-to-get-the-next-auto-increment-id-in-mysql – CBroe Jun 26 '17 at 11:18

1 Answers1

1

This is not done by wordpress. it is done by mysql. because id column is selected as primary key and auto increment . thats why when you delete and then insert another category or post and comment . this id is not repeat again .