Is there some global kind of functions.php file that works for any theme?

The problem is here:

When I change a functions.php file in any theme, I need to take care of two changes: First, I need to take care of the updates of that theme. Second, I need to take care of changing the theme of the site.

So, instead of making changes in the functions.php of a theme, is it possible to make changes in some functions.php file that is independent of any theme?

5

The difference between theme and non-theme code is organizational rather than technical. Any code that is active contributes to resulting environment, does not matter where it is loaded from.

There is number of places where code gets loaded from, which are not part of WordPress core:

  • wp-config.php configuration file
  • active theme (and its parent in for child themes)
  • active plugins
  • must use plugins
  • drop-ins (these are somewhat advanced and serve very specific purposes)

Typical place for your own code, that should not be part of theme, is to create a plugin. Other approaches do not have benefits from generic case, but forfeit interface (managing through admin area) and technical (activation/deactivation/uninstall events) conveniences of normal plugin.

Leave a Reply

Your email address will not be published. Required fields are marked *