Seeding an ID to start at something other than 1?

By: Shawn Fawcett | Asked: 06/04/2022
ForumsCategory: How-toSeeding an ID to start at something other than 1?
Shawn Fawcett asked 2 years ago
Hello all.    I'm wondering how to start an ID number in a new form entry at say 22001 instead of just 1. How would I go about doing this?
3 Answers
Best Answer
Victor Font answered 2 years ago
The [auto] shortcode accepts a start parameter,
Michael ClarkMichael Clark answered 2 years ago
Victor's right. So, given your premise, your [auto_id] shortcode would be:  
[auto_id start=22001]

Shawn Fawcett answered 2 years ago
Thank you both. The shortcode seems great but where do I put it? I didn't see anything in the the documentation and there is no field in the form (that I know of) for the Entry ID.
Michael ClarkMichael Clark replied 2 years ago

You can add a text field, visible to whomever (or only admins) or a hidden field and name it whatever you like. Put the short odd in the Default Value attribute of the filed, in that field's Advanced section.

Shawn Fawcett replied 2 years ago

Ok, so it's not actually seeding the entry ID, it is creating another ID and incrementing that one.

Victor Font replied 2 years ago

Your original question never mentioned entry id. Entry IDs are generated by WordPress. The entry id is the link between between item and item_metas table. You shouldn't change them or seed them because they are generated at the database level. Every data element added to a WordPress database receives an entry ID. If you examine the structure of any WordPress table in PHPMyAdmin, you'll see the ID field set to AUTO_INCREMENT. This means the database creates the ID when the record is inserted.

If you want to create your own numbering system, such as for invoicing or purchase orders, or some other purpose, use a text field with the shortcode as the default value. Quite often, hidden fields will be appropriate for this purpose.

Shawn Fawcett replied 2 years ago

Ok, thanks Victor

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community