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.
We've prepared a custom plugin file that you can use on your site. Here's how to get started with that code.
- Download the my-custom-code.zip plugin.
- Log into your WordPress Admin area.
- Go to Plugins > Add New > Upload
- Upload the my-custom-code.zip plugin.
- Once the plugin has been successfully installed, activate the plugin.
- To add your 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.
IMPORTANT: If the code you are pasting begins with the line <?php or 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.
Created: January 27, 2014 at 10:40 am
Updated: January 31, 2017 at 1:19 pm