wordpress 批次修改文章內容

我的網域即將到期,由於 godaddy 的續約價太盤我就直接到 cloudflare 買了個便宜的新網域但更換…

我原先在文章內插入圖片時,都是選擇 從網址插入媒體
然後輸入 https://blog.joda.tw/wp-content/uploads/imgs/…../xxx.jpg

而新的網域是 yuru.app
要把所有文章的圖片網址改成 https://blog.yuru.app/wp-content/uploads/imgs/…../xxx.jpg

一篇一篇的修改文章內容太慢了
可以透過下面方式,wordpress 批次修改文章內容
wordpress 的原始文章是存放在資料庫內的
所以我們直接連進資料庫下語法,就可以一次把所有文章的圖片網址更換

UPDATE wp_posts SET post_content = REPLACE(post_content, 'joda.tw', 'yuru.app');

另外,想從遠端連線到 NAS 的資料庫內,需要設定權限
ssh 進 NAS 後,參照下面步驟

# 1.連進資料庫
mysql -u root -p

# 2.輸入正確的密碼後,就可進入DB CLI

# 3. 設置使用者權限,單引號都要留著,IP是要連進資料庫的那台電腦的IP
GRANT ALL PRIVILEGES ON *.* TO 'your_username'@'IP' IDENTIFIED BY 'your_password' WITH GRANT OPTION;

# 4. 重新載入權限表
FLUSH PRIVILEGES;

9 則留言

  1. Excellent SQL tip for domain migrations! This REPLACE command approach is far more efficient than manual updates. For those managing content-heavy sites, similar database optimization strategies apply across platforms. Mobile-optimized platforms like phonejoy also benefit from streamlined backend operations. Thanks for sharing this practical WordPress solution!

  2. Interesting analysis! Seeing more platforms like fanduel enter the Philippines is great for players – more choice & competition. Secure verification is key, as they highlight, for a reliable experience. Solid points made in the article!

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *