3C科技 娛樂遊戲 美食旅遊 時尚美妝 親子育兒 生活休閒 金融理財 健康運動 寰宇綜合

Zi 字媒體

2017-07-25T20:27:27+00:00
加入好友
目錄 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. A Aron Data analyst, but building WordPress websites, having experience in digital marketing. Recently dives into fighting and Python quantitative investment.

本文由aronhackcom提供 原文連結

寫了 5860316篇文章,獲得 23313次喜歡
精彩推薦