Many times you want to add the custom code in the website. If the child theme is not available in the website then you can’t add custom code in the main theme.
If you will add the custom code in the main site theme then that code will remove from the website after the theme update.
If the child theme is not available then you can create a custom plugin and then you can add the code in the WordPress custom plugin.
What is the use of a custom WordPress plugin?
– In the custom WordPress plugin, you can add custom code like woocommerce-related actions, custom post type registration code, WordPress actions and etc.
How to create a custom WordPress plugin?
– Please check the below steps.
1. First of all, You need to create your custom plugin folder like vivek-custom-code
2. Then create your custom plugin file like vivek-custom-code.php
3. Open the plugin file,
4. Start the PHP and add the below information in the file.
/*
Plugin Name: Vivek Custom code
Plugin URI: https://vivekasodariya.blogspot.com/
Description: Plugin for customization
Author: VIVEK PATEL
Version: 1.0
Author URI: https://vivekasodariya.blogspot.com/
*/
You can add your own detail instead of my details. Like Plugin Name, Plugin URI, Description, Author, Version, Author URI
5. After set all the detail, Create the zip of the Plugin folder.
6. Open the WordPress website admin then install created plugin and active it.
After activating the plugin, when you want to add custom code in the plugin then open FTP and open the plugin file and insert the code after the above(step 4) details.
If you don’t have FTP detail then you need to follow below steps.
1. Click on the Install Add New plugin.
2. Search the file manager plugin and install it.
3. After installation, please click on the File Manager menu.
4. After opening the file manager, find the plugins folder, and then find the newly created plugins.
5. Then you can directly add the custom code from the WordPress dashboard.