{"id":1817,"date":"2013-05-30T06:58:45","date_gmt":"2013-05-30T06:58:45","guid":{"rendered":"http:\/\/www.withdata.com\/ad\/?p=1817"},"modified":"2025-03-21T06:37:29","modified_gmt":"2025-03-21T06:37:29","slug":"how-to-batch-replace-string-in-wordpress-posts","status":"publish","type":"post","link":"https:\/\/www.withdata.com\/blog\/mylobeditor\/how-to-batch-replace-string-in-wordpress-posts.html","title":{"rendered":"Batch replace string in WordPress posts"},"content":{"rendered":"<p>I want to change a link, from text link to image link,<\/p>\n<p>like:<br \/>\n&lt;a href=&#8221;abc.zip&#8221;&gt;download&lt;\/a&gt;<br \/>\nto<br \/>\n&lt;a href=&#8221;abc.zip&#8221;&gt;&lt;img src=&#8221;\/images\/download.gif&#8221; alt=&#8221;download&#8221; \/&gt;&lt;\/a&gt;<\/p>\n<p>And this link is not in one post, but some posts, it will spend a lot of time if I replace it one post by one.<\/p>\n<p>I tried WordPress Exporter\/Importer, but do not work, I get a doubled menu, it&#8217;s not my wanted.<br \/>\nI think it should be &#8220;Export Posts&#8221; -&gt; &#8220;Delete All Posts&#8221; -&gt; &#8220;Replace Posts&#8221; -&gt; &#8220;Import Posts&#8221;.<br \/>\nAnd I think it will change Post ID, No, I just want to update the post contents.<\/p>\n<p>So I need use some tools to do it.<\/p>\n<p>First, I use MyLobEidtor (Now <a href=\"https:\/\/www.withdata.com\/dbblobeditor\/\">DBBlobEditor<\/a>) to export from WordPress posts (Mysql database) to files.<\/p>\n<p>&#8220;Export LOB&#8221;<\/p>\n<figure id=\"attachment_1833\" aria-describedby=\"caption-attachment-1833\" style=\"width: 878px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.withdata.com\/wp\/wp-content\/uploads\/2013\/05\/mylobeditor_export_wordpress.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1833\" title=\"mylobeditor_export_wordpress\" src=\"https:\/\/www.withdata.com\/wp\/wp-content\/uploads\/2013\/05\/mylobeditor_export_wordpress.gif\" alt=\"\" width=\"878\" height=\"684\" \/><\/a><figcaption id=\"caption-attachment-1833\" class=\"wp-caption-text\">MyLobEditor Export WordPress<\/figcaption><\/figure>\n<p>Then, I use Windows Grep (<a href=\"https:\/\/www.wingrep.com\/\">https:\/\/www.wingrep.com\/<\/a>) to batch replace text in files.<\/p>\n<p><a href=\"https:\/\/www.withdata.com\/wp\/wp-content\/uploads\/2013\/05\/Windowns-Grep-Search.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1838\" title=\"Windowns-Grep-Search\" src=\"https:\/\/www.withdata.com\/wp\/wp-content\/uploads\/2013\/05\/Windowns-Grep-Search.gif\" alt=\"\" width=\"391\" height=\"444\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.withdata.com\/wp\/wp-content\/uploads\/2013\/05\/Windowns-Grep-Replace.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1837\" title=\"Windowns-Grep-Replace\" src=\"https:\/\/www.withdata.com\/wp\/wp-content\/uploads\/2013\/05\/Windowns-Grep-Replace.gif\" alt=\"\" width=\"370\" height=\"274\" \/><\/a><\/p>\n<p>Last, I use MyLobEditor (Now <a href=\"https:\/\/www.withdata.com\/dbblobeditor\/\">DBBlobEditor<\/a>) to import files to WordPress (Mysql database).<\/p>\n<p>&#8220;Import LOB&#8221;<\/p>\n<figure id=\"attachment_1836\" aria-describedby=\"caption-attachment-1836\" style=\"width: 878px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.withdata.com\/wp\/wp-content\/uploads\/2013\/05\/mylobeditor_import_wordpress.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1836\" title=\"mylobeditor_import_wordpress\" src=\"https:\/\/www.withdata.com\/wp\/wp-content\/uploads\/2013\/05\/mylobeditor_import_wordpress.gif\" alt=\"\" width=\"878\" height=\"684\" \/><\/a><figcaption id=\"caption-attachment-1836\" class=\"wp-caption-text\">MyLobEditor Import WordPress<\/figcaption><\/figure>\n<p>Note: Do not check &#8220;Use Unicode&#8221; box in MyLobEditor logon form.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I want to change a link, from text link to image link, like: &lt;a href=&#8221;abc.zip&#8221;&gt;download&lt;\/a&gt; to &lt;a href=&#8221;abc.zip&#8221;&gt;&lt;img src=&#8221;\/images\/download.gif&#8221; alt=&#8221;download&#8221; \/&gt;&lt;\/a&gt; And this link is not in one post, but some posts, it will spend a lot of time if I replace it one post by one. I tried WordPress Exporter\/Importer, but do not work, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[106],"tags":[232,231],"class_list":["post-1817","post","type-post","status-publish","format-standard","hentry","category-mylobeditor","tag-batch-replace","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/1817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/comments?post=1817"}],"version-history":[{"count":7,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/1817\/revisions"}],"predecessor-version":[{"id":27403,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/1817\/revisions\/27403"}],"wp:attachment":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/media?parent=1817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/categories?post=1817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/tags?post=1817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}