Function File
One way to change the default behaviors of WordPress is using a file named functions.php. It goes in your Theme’s folder.
The functions file behaves like a WordPress Plugin, adding features and functionality to a WordPress site. You can use it to call functions, both PHP and built-in WordPress, and to define your own functions. You can produce the same results by adding code to a WordPress Plugin or through the WordPress Theme functions file.
There are differences between the two
Plugin | Function File |
Requires specific, unique Header text. | Requires no unique Header text |
Is stored in wp-content/plugins, usually in a sub-directory. | Is stored with each Theme in the Theme’s sub-directory in wp-content/themes. |
Executes only when individually activated, via the Plugins panel. | Executes only when in the currently activated theme’s directory. |
Applies to all themes | Applies only to that theme. If the Theme is changed, the functionality is lost. |
Should have a single purpose, e.g., convert posts to Pages, offer search engine optimization features, or help with backups. | Can have numerous blocks of code used for many different purposes. |