How to avoid manually adding custom code again after upgrading your WordPress theme

888u

Last update at :2024-02-04,Edit by888u

Friends who often mess with themes know that adding code to the theme function template functions.php can increase the modification function. However, it is troublesome to add these codes again after upgrading the theme. Here is a small method to avoid repeated operations. troubles.

Save the trouble of manually adding custom code again after upgrading your WordPress theme

Some friends will think of making a sub-theme and adding custom code. The method in this article is much simpler than making a sub-theme.

The principle is to make a plug-in yourself, add custom code to it and enable it.

You may think that making a plug-in is a bit complicated, but it is actually very simple. Create a new PHP file and add the following code to it:

alert("You have successfully created your first WordPress plug-in!");'; } add_action( 'wp_footer', 'plugins_tips' );

When saving the file, you need to save the encoding as UTF-8 without BOM (no signature), otherwise garbled characters will be displayed. Then upload it to the wp-content/plugins plug-in directory and enable it on the WP background plug-in page.

Refreshing the front-end page will display a prompt dialog box, indicating that your first plug-in has been successfully created.

Making custom code into a plug-in has the same effect as adding it to the theme function template functions.php, once and for all.

Recommended solutions for bricklayers

Warm reminder: If you have difficulty choosing, just choose the CN2 GIA-E plan in the middle. The quarterly payment is $49.99, and you can switch between up to 12 computer rooms at will. plan Memory CPU harddisk Traffic/month bandwidth engine room price Buy Banwagonhost Discount Code: BWH3HYATVBJW
CN2 (cheapest) 1GB 1 core 20GB 1TB 1Gbps DC3 CN2 DC8 ZNET $49.99/year Buy
CN2 2GB 1 core 40GB 2TB 1Gbps $52.99/half year $99.99/year Buy
CN2 GIA-E (most recommended) 1GB 2 cores 20GB 1TB 2.5Gbps DC6 CN2 GIA-E DC9 CN2 GIA Japan Softbank JPOS_1 Netherlands EUNL_9 $49.99/quarter $169.99/year Buy
CN2 GIA-E 2GB 3 core 40GB 2TB 2.5Gbps $89.99/quarter $299.99/year Buy
HK 2GB 2 cores 40GB 0.5TB 1Gbps Hong Kong, China CN2 GIA $89.99/month $899.99/year Buy
HK 4GB 4 core 80GB 1TB 1Gbps $155.99/month $1559.99/year Buy
TOKYO 2GB 2 cores 40GB 0.5TB 1.2Gbps Tokyo, Japan CN2 GIA $89.99/month $899.99/year Buy
TOKYO 4GB 4 core 80GB 1TB 1.2Gbps $155.99/month $1559.99/year Buy

Recommended site searches: US host reviews, registered domain names, registered unregistered domain names, free server websites, foreign servers, network servers, vps servers, game high-defense server rentals, free personal homepage space, cn domain name prices ,

How to avoid manually adding custom code again after upgrading your WordPress theme

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码