Bulk Convert WordPress Posts To WooCommerce Products
If you want to bulk convert WordPress posts to WooCommerce products, the best way is to operate in the database, without any plugin.
Step 1. Browse Table And Backup
If you enter phpMyAdmin and check wp_posts table, you can find the columns as the screenshot The column we truly need is ‘post_type’. The post_type of WordPress posts is ‘post’, and post_type of WooCommerce products is ‘product’. As a result, the mission we need to do is change the post_type.
Before we start to edit the table, it’s strongly recommended to backup your table or whole database. Because any operation in the database may cause potential risks. To do this, you can install WordPress plugins like All-in-One WP Migration, or use the feature in phpMyAdmin > Operation tab > Copy table to.
Step 2. Modify Table With SQL
There are many other values in post_type, for example, page and revision. To prevent causing redundant rows in the table, you can add where conditions to check the data rows you will edit. The SQL code as below.
SELECT * FROM wp_posts where post_type in ('post');
Of course, you can modify the condition statement on your need, like adding post_status.
SELECT * FROM wp_posts where post_type in ('post') and post_status = 'publish'
After ensuring these are the data rows you want to edit, the core of the mission is to update data rows. Here is the SQL code.
UPDATE wp_posts SET post_type = 'product' WHERE post_type in ('post') and post_status = 'publish';
Step 3. Clear Cache
If you install any cache plugin, it is essential to purge the cache to ensure all changes work. Without this, some errors may be displayed on WooCommerce product page.
That’s all. Understanding how to operate MySQL database and write SQL code, it will be super-efficient than do it manually.