When we Create a wordpress theme or child theme. Then we we know the purpose of all templates file but we skip the functions.php. The Functions file include the functionality of the Theme and this functionality does not relate to just one page. Script in the function.php affect the whole theme.

WordPress Codex define functions.php like this:

Functions file behave like a plugin and it is used to add features and functionality to a wordpress site.You can call both php and built-in wordpress functions and can also define your own function. Same result will display by adding code to wordpress plugin or to function file.

WordPress plugins and Theme function file are similar.But it is not a good idea to write huge code in functions file. We put the code in a plugin Because if we want to change the theme then other theme have own functions file then it will overwrite but if code is Theme-dependent then functions.php is right place. Use functions.php only when you want to write functionality related to the theme otherwise for complex and extra functionality you write plugin.

Every Installed Theme have it own functions.php File But Only active theme’s file will run its code. If your theme doesn’t have functions file the you can create your functions.php file easily .Follow these steps

  • Create a plain-text file
  • Named it as functions.php
  • Paste the file in theme folder/directory

Common Uses of function.php file in WordPress Theme

Apart from the theme dependent code there are some examples that are useful.File include the wordpress actions and filter more useful are these

  • You can add theme support (feature images, post format and etc)
  • Locate the navigation menus
  • Adding,removing or overriding functionality from parent theme

Theme functions file works like a plugin but its specific to your theme. So we don’t write those function that we don’t want lose after switch themes later on .Treat your functions file with care avoid using it instead of plugin.