How do I create a custom plugin?
Sometimes you'll need to add custom code to your WordPress site in order to change the functionality of Datafeedr or WooCommerce. Adding custom code to your theme's functions.php file is OK but you run the risk of deleting all of your work when you upgrade your theme.
The best way to add custom code to your website is by writing your own WordPress plugin and adding the necessary code to that file. Don't worry! We've done most of the work for you.
We've prepared a custom plugin file that you can use on your site. Here's how to get started with it.
- Download the my-custom-code.zip plugin file.
- Log into your WordPress Admin area.
- Go to Plugins > Add New > Upload
- Upload the
- Once the plugin has been successfully uploaded, activate the plugin.
- To add custom code to the plugin, go to Plugins > Editor.
- In the upper-right corner of the Editor page select "My Custom Code" from the "Select plugin to edit" menu.
- Now you should see some code loaded in the editor. Look for the line that reads:
/** Add your custom code BELOW this line **/
- Paste the PHP code that you need underneath that line.
- After you've finished adding your custom code, click the [Update File] button.
If the code you are pasting begins with the line
<?phpor ends with the line
?>, DO NOT include those lines in your custom code. Adding those lines will potentially break your site.
Now you've added your own custom code to your site. If you need to add more code in the future, just add it below the code you just added.