Is there anyway I could convert all the posts e have right now on our WordPress install into products using some MySQL query or something like that?

  • Thank you for this... but, one also needs to convert the category type in the taxonomy table, otherwise the site gets a bit loopy! Transferring the tag type over as well is good too, if you used them. Once I also did that, categorised posts now = properly tagged and categorised products. :-) docs.woothemes.com/document/managing-product-taxonomies
    – user59521
    Sep 10, 2014 at 21:38

5 Answers 5


You could install the Post Type Switcher plugin

Or Run SQL query on your database to change the post to product post type

UPDATE  `wp_posts` SET  `post_type` =  'product' WHERE  `post_type` = 'post';

Backup your DB 1st.

UPDATE  `wp_posts` SET  `post_type` =  'wpsc-product' WHERE  `post_type` = 'post';

You can update the post_type in mysql table wp_posts update the post_type to product

sample query UPDATE wp_posts SET post_type = 'product' WHERE post_type = 'post';

  • 1
    The correct post type is 'product' not 'products', otherwise excellent solution, you do not need a plugin for something so simple. May 7, 2014 at 2:09
  • But what about populating all the products meta info, such as weight and dimensions? Going this route simply switches the posts to the right post type, but won't map the data to the appropriate locations.
    – EHerman
    Nov 12, 2014 at 20:41

Please use $wpdb to interact with the Database.

global $wpdb;
    // Table name
    // New values
    array( 'post_type' => 'product', ),
    // SQL "WHERE" clause base / affected rows
    array( 'post_type' => 'post', ),
    // Data Type (available: %s string, %d integer, %f float)
    // SQL "WHERE" clause Type

Keep in mind that this query will change the post_type of every post to product. Having a backup of your DB before doing this is recommended. It would be even better if you use a (local) test installation and refine your update process there.

More info about updating rows in the DB.

A detailed Guide on How To handle MySQL on the Command Line can be found in this extensive meta post.

  • If you are doing this using WordPress this is good advice. I would recommend however that this kind of work be done using the MySQL Workbench or the command line. And refining the process locally is a must. Nov 17, 2014 at 19:09
  • @PeterWooster We got a meta post for that - see update and link at the bottom of the answer. Aside from that, this answer is just showing an alternative to the other answers explaining the pure SQL commands (and maybe ignore the fact that some of the bits are moving targets like the DB table prefix). Also there's a note that this should be tested locally.
    – kaiser
    Nov 17, 2014 at 19:51

Additionally (optional): SQL query for converting the categories to product_cat

UPDATE `wp_term_taxonomy` SET `taxonomy`='product_cat' WHERE `taxonomy`='category'

I used https://wpsheeteditor.com/. the other solutions were great if you wanted to do all pages, I'd have done the SQL query, but there were about 30 pages that needed doing and 40 that didn't. Even if a few just needed to be changed back I'd have done that but this sheet editor plugin was a huge help.

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.