Post ids are incrementing by an unknown number?

It’s really strange, but I’ve noticed that as I’m writing and publishing posts, the ids aren’t incrementing by one, but rather by some arbitrary amount which I think is relative to the amount of times I hit preview. It’s kind of annoying to have ids like 1, 11, 29, 37, etc. Is there a way to ensure that posts only increment by one?

Related posts

Leave a Reply

1 comment

  1. Every revision or auto-draft that’s saved is added to the database and given its own auto-incremented ID. So in theory, you could turn off post revisions ( adding the line define('WP_POST_REVISIONS', false); to your wp-config.php), and be very careful to write your posts in exactly the order you want your IDs to follow, and you’d get sequentially ordered posts. (Maybe, that is – I’ve never tried, and I think there may still be an autodraft created on first visiting the post-new.php screen, so it could be that the best you can do is make sure your post IDs increment by twos.)

    This seems like a sure recipe for obsessive-compulsive disorder, though. A post ID is just a database key, no more or less, and it shouldn’t have any special meaning to you.

    If you need or want your posts to be represented by integers in some kind of logical descriptive order, there are other ways of doing that. Here’s an answer I gave to another similar question that demonstrates a way of using post meta to sequentially number posts: Display post number not post ID number