I have thousands of WooCommerce products that need to be inserted into the database. For some reasons I can't use the csv import plugin or any other 3rd party solution and this has to be done manually through php code into database.

Here is what my question is:

To what table do the product categories go ?

I guess the products have to be added to wp_posts and then the description/price etc is added to the wp_postmeta.

How to assign the products to a particular taxonomy. In which table do they go?

Don't need the code just guidelines regarding tables.


1 Answer 1


The woocommerce product category is just a custom taxonomy. As far as I know all the data is stored as intended by wordpress core. You can find out more about the database structure at the codex page Database Description, the tables you are looking for are wp_terms, wp_term_relationships and wp_term_taxonomy.

But you absolutely should look into doing this with available wordpress functions, like wp_insert_post() and wp_set_object_terms, it will make your life easier. Do a research on »programmatically adding post/custom post types« and »programmatically assign tags/categories«, here on WPSE is more then enough information about that available. Besides that you really, really should read the woocommerce source thoroughly, to make sure you're going to resemble all the steps creating a product correctly.

Btw you can ask WooCommerce questions at the official WooCommerce Q&A.

Note: it just did not want to fit into a comment


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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