{"id":6481,"date":"2026-10-27T07:38:24","date_gmt":"2026-10-26T22:38:24","guid":{"rendered":"https:\/\/the-world-star.com\/?p=6481"},"modified":"2026-11-15T10:15:22","modified_gmt":"2026-11-15T01:15:22","slug":"how-to-stop-wordpress-theme-updates-from-overwriting-custom-code","status":"publish","type":"post","link":"https:\/\/the-world-star.com\/en\/server\/how-to-stop-wordpress-theme-updates-from-overwriting-custom-code-6481\/","title":{"rendered":"How to Stop WordPress Theme Updates from Overwriting Custom Code"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">During a server migration to an AWS Lightsail Amazon Linux blueprint, I safely migrated and restored custom modifications across four separate areas into a child theme (lightning-child) so they won't get wiped out whenever the parent theme (Lightning) updates. Here is a log of the entire process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/the-world-star.com\/server\/post-88-4038\/\">Summary of Changes<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">1. Child Theme Files Created<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Root directory of the new child theme:<code>\/var\/www\/html\/wp-content\/themes\/lightning-child\/<\/code><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th class=\"has-text-align-left\" data-align=\"left\">\u5bfe\u8c61\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9<\/th><th class=\"has-text-align-left\" data-align=\"left\">\u4f5c\u696d\u533a\u5206<\/th><th class=\"has-text-align-left\" data-align=\"left\">\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u306e\u76ee\u7684\u3068\u6982\u8981<\/th><\/tr><\/thead><tbody><tr><td><code>style.css<\/code><\/td><td><strong>\u65b0\u898f\u8ffd\u52a0<\/strong><\/td><td><strong>\u5b50\u30c6\u30fc\u30de\u306e\u5b9a\u7fa9<\/strong><\/td><\/tr><tr><td><code>functions.php<\/code><\/td><td><strong>\u65b0\u898f\u8ffd\u52a0\uff0b\u30b3\u30fc\u30c9\u8ffd\u8a18<\/strong><\/td><td><strong>\u5404\u7a2e\u6a5f\u80fd\u306e\u8ffd\u52a0<\/strong>\uff08\u30a2\u30fc\u30ab\u30a4\u30d6\u6574\u7406\u30fb\u65e5\u672c\u8a9e\u30b9\u30e9\u30c3\u30b0\u5909\u63db\uff09<\/td><\/tr><tr><td><code>_g3\/template-parts\/next-prev.php<\/code><\/td><td><strong>\u30b3\u30d4\u30fc\uff0b\u30b3\u30fc\u30c9\u4fee\u6b63<\/strong><\/td><td><strong>\u524d\u5f8c\u306e\u8a18\u4e8b\u306e\u540c\u30ab\u30c6\u30b4\u30ea\u9650\u5b9a\u5316<\/strong><\/td><\/tr><tr><td><code>_g3\/template-parts\/sidebar-contents-post.php<\/code><\/td><td><strong>\u30b3\u30d4\u30fc\uff0b\u30b3\u30fc\u30c9\u4fee\u6b63<\/strong><\/td><td><strong>\u30b5\u30a4\u30c9\u30d0\u30fc\u300c\u6700\u8fd1\u306e\u6295\u7a3f\u300d\u306e\u540c\u30ab\u30c6\u30b4\u30ea\u9650\u5b9a\u5316<\/strong><\/td><\/tr><tr><td><code>_g3\/template-parts\/page-header.php<\/code><\/td><td><strong>\u30b3\u30d4\u30fc\uff0b\u30b3\u30fc\u30c9\u4fee\u6b63<\/strong><\/td><td><strong>\u30ab\u30c6\u30b4\u30ea\u30fc\u30c8\u30c3\u30d7\u3078\u306e\u753b\u50cf\u8868\u793a<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2. Detailed Customizations by File<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For the full code snippets and complete implementation details, please refer to the original post: \"Summary of WordPress Custom Code Locations.\"<\/p>\n\n\n<ul class=\"wp-block-list\">\n\n<li><strong>style.css<\/strong>: Added the required header declarations so WordPress recognizes it as a child theme.<\/li>\n\n\n<li><strong>next-prev.php<\/strong>: Modified previous\/next post links to navigate strictly within the same category.<\/li>\n\n\n<li><strong>sidebar-contents-post.php<\/strong>: Added query conditions to fetch and display posts only from the current category.<\/li>\n\n\n<li><strong>page-header.php<\/strong>: Built custom logic to integrate with a plugin, overlaying the category title over the header image.<\/li>\n\n\n<li><strong>functions.php<\/strong>: Configured archive layout adjustments and automated conversion for Japanese URL slugs.<\/li>\n\n<\/ul>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3. Server Permissions & Security Settings (Crucial)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once the changes were in place, file ownership and permissions were properly reconfigured to ensure WordPress can securely read and write files.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chown -R www-data:www-data \/var\/www\/html\/wp-content\/themes\/lightning-child\/\nfind \/var\/www\/html\/wp-content\/themes\/lightning-child\/ -type f -exec chmod 644 {} ;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With this setup, the site is now safely insulated from future parent theme updates.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting the Japanese Slug Conversion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This feature wouldn't work at first and proved pretty tricky to solve, but Gemini guided me through the fix.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. Switched the hooked action function<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. Flushed the permalinks by re-saving under Settings > Permalinks<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>During a server migration to an AWS Lightsail Amazon Linux blueprint, I safely migrated and restored custom modifications across four separate areas into a child theme (lightning-child) so they won't get wiped out whenever the parent theme (Lightning) updates. Here is a log of the entire process. Summary of Changes 1. Child Theme Files Created [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2606,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"https:\/\/the-world-star.com\/?p=6150","_lightning_design_setting":[],"footnotes":""},"categories":[3],"tags":[67,68,81,278,694,1086,1087,1088,1089],"class_list":["post-6481","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-server","tag-wordpress","tag-lightning","tag-php","tag-debian","tag-customization","tag-theme-migration","tag-backup","tag-child-theme","en-US"],"_links":{"self":[{"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/posts\/6481","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/comments?post=6481"}],"version-history":[{"count":1,"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/posts\/6481\/revisions"}],"predecessor-version":[{"id":6482,"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/posts\/6481\/revisions\/6482"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/media\/2606"}],"wp:attachment":[{"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/media?parent=6481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/categories?post=6481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/the-world-star.com\/wp-json\/wp\/v2\/tags?post=6481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}