search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

Bulk Convert WordPress Posts To WooCommerce Products | ARON HACK 亞倫害的

目錄

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.

convert_wp_post_to_wc_product

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.

Content Protection by DMCA.com
A
Aron

Data analyst, but building WordPress websites, having experience in digital marketing. Recently dives into fighting and Python quantitative investment.



熱門推薦

本文由 aronhackcom 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦