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.

  1. Download the my-custom-code.zip plugin file.
  2. Log into your WordPress Admin area.
  3. Go to Plugins > Add New > Upload
  4. Upload the my-custom-code.zip plugin file.
  5. Once the plugin has been successfully uploaded, activate the plugin.
  6. To add custom code to the plugin, go to Plugins > Editor.
  7. In the upper-right corner of the Editor page select "My Custom Code" from the "Select plugin to edit" menu.
  8. Now you should see some code loaded in the editor. Look for the line that reads:
    /** Add your custom code BELOW this line **/
    	
  9. Paste the PHP code that you need underneath that line.
  10. After you've finished adding your custom code, click the [Update File] button.
Plugin editor screen

Important

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.

Still need help? Contact Us Contact Us