Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

separate functions.php from theme WordPress



I have a wordpress multitise setup with a number of themes, as I add additional functionality its been included in the functions.php file. I am worried that its going to be tricky to manage this additional functionality and I dont want to have to update each theme individually as I bring in new code or themes

Is there a way to have a extra functions.php type file that can be shared with all themes?

Answers (5)


John Cotton answers:

Child themes are the way to go....

Create your core functionality in a parent theme and then do the design and mod etc in a child them

npeplow comments:

Hi John

I am looking to mainly use off the shelf template themes, will this be a lot of additional work on each one?

John Cotton comments:

No. To make a theme a child, you just add this to styles.css comment block:

Template: your_parent_them_directory_name

The only work you might have is if you update the child theme - you'd need to add that line back in.

John Cotton comments:

Your parent theme would just have style.css and functions.php files....

John Cotton comments:

The suggestions of a plugin and require/includes are both valid.

But a parent theme is a more WordPress approach and you should always try to go with the grain of WordPress if you can - it'll reward you for the effort.

A plugin would have the advantage of being loaded prior to the theme so could be attractive for that reason. But if you've got a variety of things the code needs to do, you would end up with a very broad plugin, or a series of smaller ones, neither of which is desirable.


Francisco Javier Carazo Gil answers:

Moreover, you can use [[LINK href=""]]require[[/LINK]] or [[LINK href=""]]include[[/LINK]] directives of PHP.

npeplow comments:

which file do these get included into, the header?

Francisco Javier Carazo Gil comments:

You should create an empty functions.php in your theme and then include here the file that will implement all you want that will be placed in another path.


Lee Rickler answers:

I suggest you create a mu plugin which, by definition, is loaded by default on the whole install - multi-site/ network or not.

Check here for more details:
[[LINK href=""]][[/LINK]]


Charles Klycinski answers:

You can also make some plugin which contains all of configuration things.


Luis Abarca answers:

I have a multisite installation and i created a Plugin with All the common ir global functions and mods, then go to network admin and activate that Plugin, this way all sites can call functions and their logo on login page us changed to the parent site logo