I have a lot of custom code in my functions.php file, what I would like to do is move all of this into a plugin for example myplugin-functions.php and then include the file into the themes functions.php file.

Can I use hooks to do this or would I have to manually include the file. The reason I want it as a plugin is so that I can easily disable it without editing theme files!


4 Answers 4


You can directly create a plugin. Just copy all your codes and put it in a new folder. Plugin will call all the functions.

  • 1
    Ah ok so if I just set it up as a plugin, and activate the plugin all the functions will be called anyway - so no need to include the code into my functions.php file?
    – RuFFCuT
    Commented Oct 29, 2013 at 11:55
  • Yes, you can do that, best thing about creating a plugin is.....it doesn't depend on your theme and if you want to use it in particular theme....you can activate/deactivate the plugin. Commented Oct 30, 2013 at 5:59

The Best way to this is to copy the code into something like custom-functions.php page and the include it in the functions.php page.

You can add include 'custom-functions.php'; code to your functions.php file in order to include custom-functions.php.

Remember the custom-functions.php must be in theme folder or define the path to it.

Hope this worked for you.

  • Thanks for answering, I have thought of doing I like this before - but ideally I would like it to be a plugin is there not a way to automatically add the "include 'custom-functions.php'" into the functions.php file?
    – RuFFCuT
    Commented Oct 29, 2013 at 11:50
  • Oh i got that you mean that you want to create plugins so instead of describing the procedure please follow instruction here : doitwithwp.com/create-functions-plugin Commented Oct 29, 2013 at 12:15

You can also use funtionality plugin

A functionality plugin is a way to separate what you might normally place in a theme's functions.php file, and put it in a plugin instead. It works the same way as a theme functions.php file, but is separate from the theme and so not affected by theme upgrades, or tied to the theme so you loose all of your functions if you choose to switch themes.

This plugin automates the process of creating a functionality plugin. Simply install and activate this plugin, and your very own functionality plugin will be created for you. You can then edit your functionality plugin and add snippets to it using the quick link in the admin menu.


There is no point to create a plugin just in order to clean up your code. a plugin should be created only if it has some functionality that can be used not only with your theme.

If you have some code that you might want to dynamically disable its execution then it is better to have a setting for it in your theme's settings page then to have a plugin for that.

as for how you should organize your files and should you create actions, you will have to be more specific about your code and what it does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.