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?

1 Answer 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

  • 2
    that table also stores pages, attachments, and nav menu items, you couldn't use any of those things either.
    – Milo
    Aug 24, 2011 at 20:36
  • 1
    @Milo - oh yeah, that's true, too. Wasn't even thinking about all of those! Aug 24, 2011 at 20:39
  • Yep, it's OCD to the extreme. Aug 24, 2011 at 21:01
  • I'm creating pages via command line with wp-cli Despite this my IDs are still incrementing unexpectedly. I have not visited the backend of my site and gone in to edit any pages so I'm not sure why auto-draft or revisions would be in play here. OCD? No. Consistency makes for script reliability. Especially when your script is editing pages based solely on their ID#
    – Jay
    Mar 28, 2018 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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