How WordPress generates IDs for products

This topic has 4 replies, 2 voices, and was last updated 3 months ago ago by Rok

  • Avatar: Rok
    Rok
    Participant
    September 3, 2025 at 05:49

    Hello,

    Can you please clarify what algorithm WooCommerce (or WordPress) follows when generating ID numbers for new products?

    I ask because I don’t see any consistency. For example, during one import these IDs were generated:

    7751
    7773
    7775
    7759
    7761
    7763, 7764, 7765, 7766, 7767
    7769
    7771

    As you can see, some numbers follow sequentially while others skip. Later on, the next automatically generated number was 7851.

    I would like to understand why IDs are sometimes consecutive and sometimes skipped. This is important for me because when importing variations through CSV I need to predefine the parent product’s ID.

    Thanks

    3 Answers
    Avatar: Alex Carter
    Alex Carter
    Support staff
    September 3, 2025 at 06:28

    Hello,

    Thank you for reaching out to us.

    Regarding your question about how WooCommerce (or WordPress) generates ID numbers for new products — WordPress uses an auto-incrementing system for post IDs, which includes products, pages, posts, attachments, and other custom post types. This means that every time a new post of any type is created, the system assigns the next available ID in the sequence.

    The reason you may see gaps or non-sequential IDs is because IDs are not reserved exclusively for products. For example, when you import products, WordPress may also create associated entries such as product variations, images (attachments), or temporary drafts, each of which receives its own ID. If a post is created and then deleted or if the import process creates temporary entries, those IDs are still consumed and will not be reused, which can result in apparent gaps in the sequence.

    This behavior is expected and is part of how WordPress manages content internally. Therefore, when importing variations via CSV, it is recommended to first import the parent products, retrieve their assigned IDs, and then use those IDs when importing the variations.

    We hope this clarifies the situation.

    Here is a link to the WooCommerce support forum – https://wordpress.org/support/plugin/woocommerce/

    Best Regards,
    8Theme’s Team

    Avatar: Rok
    Rok
    Participant
    September 3, 2025 at 06:30

    I got it, thanks

    Avatar: Rok
    Rok
    Participant
    September 3, 2025 at 06:30

    Thanks for the support! My topic “How WordPress generates IDs for products” has been successfully resolved.

  • Viewing 4 results - 1 through 4 (of 4 total)

The issue related to '‘How WordPress generates IDs for products’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.