SELECT p.ID as product_id, p.post_title as product_name, sku.meta_value as sku, price.meta_value as price FROM wp_posts p LEFTJOIN wp_postmeta sku ON p.ID = sku.post_id AND sku.meta_key ='_sku' LEFTJOIN wp_postmeta price ON p.ID = price.post_id AND price.meta_key ='_price' WHERE p.post_type ='product' AND p.post_status ='publish' AND ( sku.meta_value ISNULLOR sku.meta_value ='' OR price.meta_value ISNULLOR price.meta_value ='' );
print('-----------------------------------------------END-----------------------------------------------') print('SUCCESS: %d files have been pushed to {0}.'.format(domain) % md_cnt)
iflen(failpaths) > 0: print('WARNING: %d files haven\'t been pushed to {0}.'.format(domain) % len(failpaths)) print('\nFailure to push these file paths:') for failpath in failpaths: print(failpath)
第137行 post = make_post(filepath, post_metadata) 这个需要try catch
添加排序功能: 目前加载目录下的文件没有排序, 请按文件的英文字母顺序排序
请排除目录名中包含secret的目录
运行后输出:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
----------------------------------------------START---------------------------------------------- Process number: 8/418 SUCCESS: Push "1099-MISC是什么-CarlZeng.md" completed! Process number: 9/418 SUCCESS: Push "A-feature-in-Netsuite-Reports-Financial-Balance-Sheet-CarlZeng.md" completed! Process number: 10/418 SUCCESS: Push "AI脸部识别,人脸比对,人脸识别-CarlZeng.md" completed! Process number: 11/418 SUCCESS: Push "AJAX提交数据时-中文处理-以及js-url-中文处理-CarlZeng.md" completed! Process number: 12/418 SUCCESS: Push "Bar-codes-in-NetSuite-Saved-Searches-transport-reprint-活用NetSuite搜索页面显示可扫描条码-CarlZeng.md" completed!
...
Process number: 417/418 SUCCESS: Push "高手写出的是天使,而新手写的,可能是魔鬼!-Javascript这样的脚本语言,由于太灵活-CarlZeng.md" completed! Process number: 418/418 SUCCESS: Push "高效的服务端生成QRCODE二维码方案-Docker搭建.md" completed! -----------------------------------------------END----------------------------------------------- SUCCESS: 411 files have been pushed to https://wp.carlzeng.com:3/. WARNING: 7 files haven't been pushed to https://wp.carlzeng.com:3/.
Failure to push these file paths: /Users/carlzeng/App/blog/source/_posts/.DS_Store
遇到的bug/enhancement:
手动完成文章所有分类,
标签和照片无法导入; (用python, 等待更新, 提取这些信息到WP)
下一步:
Woocommerce下单错误
点击下单报错:
1
Uncaught Error: Call to a member function get_total() on false in /var/www/html/wp-content/plugins/woocommerce/includes/gateways/cod/class-wc-gateway-cod.php:314\nStack trace:\n#0 /var/www/html/wp-content/plugins/woocommerce/src/StoreApi/Legacy.php(56): WC_Gateway_COD->process_payment(4131)\n#1 /var/www/html/wp-includes/class-wp-hook.php(341): Automattic\\WooCommerce\\StoreApi\\Legacy->process_legacy_payment(Object(Automattic\\WooCommerce\\StoreApi\\Payments\\PaymentContext), Object(Automattic\\WooCommerce…wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters(NULL, Array)\n
SELECT p.* FROM wp_posts p JOIN wp_term_relationships tr ON p.ID = tr.object_id JOIN wp_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.term_id =22-- 分类ID 22 AND tt.taxonomy ='category'-- 只查文章分类,不查标签/自定义分类 AND p.post_type ='post'-- 只查文章 AND p.post_status ='publish'-- 只查已发布 ORDERBY p.post_date DESC;
继续在新的系统中编辑这些文章
修改域名, 和导入的文章URL需要修改
1 2 3 4 5 6 7 8 9 10 11
-- 3. 文章/页面里的URL(含GUID) SELECT'wp_posts'AS src, CONCAT(ID,':',post_title) AS name, guid FROM wp_posts WHERE guid LIKE'http%'
UNIONALL
-- 4. 文章自定义字段里的URL SELECT'wp_postmeta'AS src, meta_key, meta_value FROM wp_postmeta WHERE meta_value LIKE'http%';
1 2 3 4 5 6 7 8 9 10 11 12 13
UPDATE wp_posts SET post_content=REPLACE(post_content,'http://192.168.6.203:8108','https://netsuite.carlzeng.com'), guid=REPLACE(guid,'http://192.168.6.203:8108','https://netsuite.carlzeng.com'); UPDATE wp_posts SET post_content=REPLACE(post_content,'https://w.carlzeng.com','https://netsuite.carlzeng.com'), guid=REPLACE(guid,'https://w.carlzeng.com','https://netsuite.carlzeng.com'); --手动更新了一行 -- 4. 文章自定义字段里的URL SELECT 'wp_postmeta' AS src, meta_key, meta_value, * FROM wp_postmeta WHERE meta_value LIKE 'http%';
如何修复错误 “Too Many Redirects” WordPress 报错 (ERR_TOO_MANY_REDIRECTS)
INSERT IGNORE INTO wp_term_relationships (object_id, term_taxonomy_id, term_order)
select ID, 22, 0 from wp_posts where post_type = 'post' and post_content like '%netsuite%' or post_title like '%netsuite'
note: 用IGNORE支持多次执行, 会避开重复的行, 输出
1 2 3 4 5 6 7
Duplicate entry '205-22' for key 'PRIMARY' Duplicate entry '3298-22' for key 'PRIMARY' Duplicate entry '3306-22' for key 'PRIMARY' Duplicate entry '3312-22' for key 'PRIMARY' Duplicate entry '3640-22' for key 'PRIMARY' Duplicate entry '3662-22' for key 'PRIMARY'
步骤二: 插入wp_term_taxonomy
1 2 3 4 5 6 7 8
#关键后续:更新 WordPress 分类计数器 UPDATE wp_term_taxonomy SET count = ( SELECT COUNT(*) FROM wp_term_relationships WHERE wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id ) WHERE term_taxonomy_id = 22
添加剩余的文章都分类到: 一修哥工作室
1 2 3 4 5 6 7 8 9 10 11 12
INSERT IGNORE INTO wp_term_relationships (object_id, term_taxonomy_id, term_order) select ID, 23, 0from wp_posts where post_type ='post'and ID notin ( select object_id from wp_term_relationships )
UPDATE wp_term_taxonomy SET count = ( SELECTCOUNT(*) FROM wp_term_relationships WHERE wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id ) WHERE term_taxonomy_id =23
SELECT ID, post_title, post_date FROM wp_posts WHERE post_content LIKE'%13261977480%';
-- 1. 替换文章正文内容(最核心) UPDATE wp_posts SET post_content = REPLACE(post_content, '13261977480', '1326****480') WHERE post_content LIKE'%13261977480%';
UPDATE wp_posts SET post_content = REPLACE(post_content, '后北营家园一区10号楼3-130', '后北营家园一区10号(大运河果蔬便民店外)') WHERE post_content LIKE'%后北营家园一区10号楼3-130%';
UPDATE wp_posts SET post_content = REPLACE(post_content, 'VPN', 'V*P*N') WHERE post_content LIKE'%VPN%';
-- 替换文章标题 UPDATE wp_posts SET post_title = REPLACE(post_title, '_2026-05-17', '_手柄一修哥') WHERE post_title LIKE'%_2026-05-17%';
维护商品分类
1 2 3 4 5 6 7 8
INSERT IGNORE INTO wp_term_relationships (object_id, term_taxonomy_id, term_order) SELECT ID, 17, 0 FROM wp_posts WHERE post_type ='product' AND post_title like'%PS5%'
and ID notin ( select object_id from wp_term_relationships)
INSERT IGNORE INTO wp_term_relationships (object_id, term_taxonomy_id, term_order) SELECT ID, 27, 0 FROM wp_posts WHERE post_type ='product' AND post_title like'%switch%'
INSERT IGNORE INTO wp_term_relationships (object_id, term_taxonomy_id, term_order) SELECT ID, 27, 0 FROM wp_posts WHERE post_type ='product' AND post_title like'%joycon%'
SELECT ID, 27, 0 FROM wp_posts WHERE post_type ='product' and wp_posts.ID notin ( select object_id from wp_term_relationships )
#更新分类的统计表 UPDATE wp_term_taxonomy SET count = ( SELECTCOUNT(*) FROM wp_term_relationships WHERE wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id ) WHERE term_taxonomy_id =34