How to create a WordPress plugin for your custom functions

Typically WordPress plugins are for a single purpose – such as a tool, and any custom functions you need are added to your active theme’s functions.php file.

The issue with this is that each time the theme is updated you lose the changes made to the functions.php file.

One way around this is to create a child theme – but it still has it’s own limitations, such as the plugins_loaded action hook doesnt fire because it needs to be called before the theme has loaded.

The answer to this is to create a simple custom plugin that can contain all your custom functions. This way you can update your theme without worrying about loosing any of your customisations.


There are other advantages to this – it’s easier to maintain as you can use the plugin version number to create your own version control, and easier to debug – if you have any issues you can just disable the plugin to see if the issues are caused by your customisations.

Here’s what you need to do.

  1. Using the sample plugin header below, copy to a new text file and save as a PHP file. For example itsg-custom-functions.php
  2. <?php
    Plugin Name: custom functions
    Description: Contains custom functions
    Version: 1.0.0
    Author: IT Support Guides
    Author URI:
  3. Add your custom functions below the closing */
  4. TIP: make sure that you do not have the same functions anywhere else – such as the themes function.php file.
  5. ZIP the file up, so you have something like this sample plugin:
  6. Now open up the WordPress administration console
  7. Open the Plugins page and click on ‘Add Plugin’
  8. WordPress-CustomPlugin2
  9. Now click on the ‘Upload Plugin’ button and upload the ZIP’ed plugin file
  10. WordPress-CustomPlugin3
  11. Activate the plugin
  12. You can now maintain all your custom functions from the plugin instead of your theme’s functions.php file.

Stuck? Have a look at my sample plugin:

Related Articles

Leave a Reply

Your email address will not be published.