Instructions to change the wordpress theme directory without losing the theme configuration
Hi guys, when you make a wordpress theme, you must have encountered a situation where you want to edit the theme's folder name, but after renaming the theme, the theme loses all old configs, this article I will guide you how to solve it. This problem.
For example, my situation below has a folder named themecu and I want to rename the folder to thememoi
Step 1: Go to Php Myadmin and query this command line to get the old configurations (if you have database knowledge, it will be easy to understand this command):
SELECT * FROM `wp_options` WHERE option_name like "%theme_mods_themecu%";
Get the entire value in the option_value column when the value is selected to the mysql interface and copy it to notepad to save
Step 2: rename your theme folder. For example, I renamed the folder wp-content/themes/themecu to wp-content/themes/thememoi
Step 3: Edit the style.css file in the theme's root directory according to the following structure:
/* this should be at the top of your theme CSS file Theme Name: Ten theme moi Theme URI: https://web888.vn/ Description: Tech888 Theme Author: Toanngo92 Author URI: http://toanngo.trienkhaiweb.com Template: thememoi Version: 1.0.0 License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready Text Domain: textdomaincu */
I leave the textdomain as the old theme so that the old translations do not have any problems, if you have time, you can change the textdomain for the whole project.
Step 4: go to the wordpress admin, select the apperance and themes menu to re-activate the theme, because after renaming the folder, the current theme will be deactivated because the old theme information is not found.
Step 5: Access phpmyadmin and query the command to get the new option and update the value just copied in notepad:
SELECT * FROM `wp_options` WHERE option_name like "%theme_mods_thememoi%"; //cau lenh de update hoặc bạn có thể update trực tiếp ngoài giao diện luôn UPDATE `wp_options` SET `option_value` = '<option vừa copy từ nodepad>'
In addition, in case you need to change the directory of the childtheme, we do the same to change the parent theme, only the templates line is at the comment position at the top of the css file, we change the template name to the parent theme, like code bullets. pineapple side
/* this should be at the top of your theme CSS file Theme Name: Ten theme moi Child Theme URI: https://web888.vn Description: Tech888 Child Theme Author: Toanngo92 Author URI: https://web888.vn Template: thememoi-child Version: 1.0.0 License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready Text Domain: textdomaincu Template: thememoi */
Refer to the community article at https://stackoverflow.com/questions/36120925/can-i-change-the-theme-name-in-wordpress/ , if you have any questions, please comment at the post, Our team will help!