{"id":5,"date":"2022-07-15T16:08:17","date_gmt":"2022-07-15T16:08:17","guid":{"rendered":"https:\/\/www.ddzheng.cc\/?p=5"},"modified":"2022-07-18T10:27:13","modified_gmt":"2022-07-18T10:27:13","slug":"change-wordpress-domain-name-with-elementor-content-%e6%9b%b4%e6%94%b9%e6%9c%89elementor%e5%86%85%e5%ae%b9%e7%9a%84wordpress%e7%ab%99%e7%82%b9%e5%9c%b0%e5%9d%80","status":"publish","type":"post","link":"https:\/\/www.ddzheng.cc\/?p=5","title":{"rendered":"Change WordPress Domain Name with Elementor Content \u66f4\u6539\u6709Elementor\u5185\u5bb9\u7684WordPress\u7ad9\u70b9\u5730\u5740"},"content":{"rendered":"<h2 class=\"simpletoc-title\">Table of Contents<\/h2>\n<ul class=\"simpletoc-list\">\n<li><a href=\"#backup-database-%25e5%25a4%2587%25e4%25bb%25bd%25e6%2595%25b0%25e6%258d%25ae%25e5%25ba%2593\">Backup Database \u5907\u4efd\u6570\u636e\u5e93<\/a>\n\n<\/li>\n<li><a href=\"#modify-database-to-change-domain-name-%25e4%25bf%25ae%25e6%2594%25b9%25e6%2595%25b0%25e6%258d%25ae%25e5%25ba%2593%25e4%25b8%25ad%25e5%259f%259f%25e5%2590%258d\">Modify Database to Change Domain Name \u4fee\u6539\u6570\u636e\u5e93\u4e2d\u57df\u540d<\/a>\n\n<\/li>\n<li><a href=\"#restore-database-%25e8%25bf%2598%25e5%258e%259f%25e6%2595%25b0%25e6%258d%25ae%25e5%25ba%2593\">Restore Database \u8fd8\u539f\u6570\u636e\u5e93<\/a>\n<\/li><\/ul>\n\n\n<p>It is a pain in the a** to change a WordPress site&#8217;s address or URL, more so if you use Elementor. Elementor stores text differently than vanilla WordPress. In order to migrate a WordPress site with Elementor-created content to another domain name or URL, following steps were executed.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"backup-database-%25e5%25a4%2587%25e4%25bb%25bd%25e6%2595%25b0%25e6%258d%25ae%25e5%25ba%2593\">Backup Database \u5907\u4efd\u6570\u636e\u5e93<\/h1>\n\n\n\n<p>You can use your trusted database management tools to back up database. Or a SQL dump file can be generated by using the following command under linux:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysqldump -u<em>youruser<\/em> -p<em>yourpassword<\/em> <em>wordpress<\/em> &gt; wordpress.sql<\/code><\/pre>\n\n\n\n<p>Replace <em><code>youruser<\/code><\/em> with your MySQL user name, <em><code>yourpassword<\/code><\/em> with your MySQL password, and database name with you actual database name if it is not &#8220;<code>wordpress<\/code>&#8220;. The command create <code>wordpress.sql<\/code> at current directory, which can later be imported into MySQL if things go wrong.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"modify-database-to-change-domain-name-%25e4%25bf%25ae%25e6%2594%25b9%25e6%2595%25b0%25e6%258d%25ae%25e5%25ba%2593%25e4%25b8%25ad%25e5%259f%259f%25e5%2590%258d\">Modify Database to Change Domain Name \u4fee\u6539\u6570\u636e\u5e93\u4e2d\u57df\u540d<\/h1>\n\n\n\n<p>Next step is to alter the database content to change all old domain name to new domain name. The following SQL queries update wordpress internal data about site URL.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UPDATE `wp_options` SET `option_value` = '<em>newUrl<\/em>' WHERE `wp_options`.`option_name` = 'siteurl';\nUPDATE `wp_options` SET `option_value` = '<em>newUrl<\/em>' WHERE `wp_options`.`option_name` = 'home';\n\nUPDATE wp_posts SET guid = replace(guid, 'oldUrl', 'newUrl');\n\nUPDATE wp_links SET link_url = replace(link_url, 'oldUrl','newUrl');<\/code><\/pre>\n\n\n\n<p>The following updates URLs in post bodies. However, if your URL has sub directory these queries will not match.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UPDATE wp_posts SET post_content = replace(post_content, 'oldUrl', 'newUrl');\n\nUPDATE wp_postmeta SET meta_value = replace(meta_value,'oldUrl','newUrl');<\/code><\/pre>\n\n\n\n<p>If sub directory is involved, you need to use the following SQL queries as elementor use <code>\\<\/code> to escape <code>\/<\/code>, and SQL use <code>\\<\/code> to escape <code>\\<\/code>, so for every <code>\/<\/code> in actual text, a <code>\\\\\/<\/code> is used in SQL query:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\nUPDATE wp_postmeta SET meta_value = replace(meta_value,'http:\\\\\/\\\\\/oldUrl\\\\\/path','http:\\\\\/\\\\\/newUrl\\\\\/path');\n\nUPDATE wp_posts SET post_content = replace(post_content, 'http:\\\\\/\\\\\/oldUrl\\\\\/path', 'http:\\\\\/\\\\\/newUrl\\\\\/path');\n<\/code><\/pre>\n\n\n\n<p>You need to run both of the above queries as both WordPress and Elementor content needs to be updated.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"restore-database-%25e8%25bf%2598%25e5%258e%259f%25e6%2595%25b0%25e6%258d%25ae%25e5%25ba%2593\">Restore Database \u8fd8\u539f\u6570\u636e\u5e93<\/h1>\n\n\n\n<p>If you used <code>mysqldump<\/code> to backup MySQL, pipe the file into MySQL will restore its content.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u<em>youruser<\/em> -p<em>yourpassword<\/em> wordpress &lt; wordpress.sql<\/code><\/pre>\n\n\n\n<p>Replace <code>youruser<\/code>, <code>yourpassword<\/code> and database name accordingly. You may need to clear out the database before proceeding with restoration.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This posts describe how to change domain name or URL of a Wordpress site with Elementor <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[14,15,10],"class_list":["post-5","post","type-post","status-publish","format-standard","hentry","category-tech","tag-software","tag-web","tag-writeup"],"_links":{"self":[{"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=\/wp\/v2\/posts\/5","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5"}],"version-history":[{"count":7,"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=\/wp\/v2\/posts\/5\/revisions"}],"predecessor-version":[{"id":57,"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=\/wp\/v2\/posts\/5\/revisions\/57"}],"wp:attachment":[{"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ddzheng.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}