How to Change the Default Length of Post IDs in WordPress

I’m trying to change how the post IDs are formatted in WordPress for my new post types. Currently, the IDs are too short, like 62 or 145. I would prefer them to have a longer format.

For instance, instead of seeing:

I would like it to appear as:

I aim to establish a minimum length for these post IDs. However, I can’t find any relevant filters or documentation in WordPress that would help with this issue.

Can someone guide me on how to achieve this? Is it possible to use a custom function in the theme’s functions.php or perhaps use a specific plugin? I’d appreciate any suggestions!

i get where ur coming from, but messing with post IDs can really mess up things like tracking or even plugin compatibility. it’s usually better to stick with the defaults, but yeah, custom permalinks are a safer way to go for nicer urls!

You can’t easily modify WordPress post IDs since they’re auto-incremented primary keys in the database. Messing with the ID generation process will likely break core WordPress features and plugins. Here’s a better approach: create a custom field that generates your format and use it for permalinks or display. Hook into wp_insert_post to generate something like “62345678” and save it as post metadata. Then modify your permalink structure to use this custom value instead of the default post ID. This way you get your formatting without breaking the database.

Had this exact problem building a client portal that needed longer reference numbers for posts. Here’s what worked: I created a custom post meta field that stores a formatted ID when the post gets created. Hooked into save_post and generated a padded number using the real post ID plus some padding logic. Then I modified the URL rewrite rules to accept both formats but still use the actual post ID for database queries internally. The tricky bit was making sure the custom URLs resolved properly - had to add custom rewrite rules in functions.php and flush permalinks. Just remember you’ll need to update any hardcoded post ID references in your theme files to show the formatted version instead.