WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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

share|improve this answer
that table also stores pages, attachments, and nav menu items, you couldn't use any of those things either. – Milo Aug 24 '11 at 20:36
@Milo - oh yeah, that's true, too. Wasn't even thinking about all of those! – goldenapples Aug 24 '11 at 20:39
Yep, it's OCD to the extreme. – Naftuli Tzvi Kay Aug 24 '11 at 21:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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