> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.ex2.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# What is the WordPress functions.php file?

The functions.php file (or theme function file) is a template included in WordPress themes. The functions.php file behaves like a WordPress plugin, adding tools and features to a WordPress site. 

The file activates automatically when you enable a WordPress theme. It uses [PHP](https://help.ex2.com/en/article/what-is-php-and-what-is-it-used-for-x4xvdq/?bust=1784054117446) code to change the default features of the [CMS](https://help.ex2.com/en/article/what-is-a-content-management-system-or-cms-1c48kdh/?bust=1784052067814) or add new ones.

Editing functions.php with custom codes allows you to improve your site. You can add with taxonomies, shortcodes, item types, and more. For example, a theme can use the theme’s functions.php file to add a custom welcome message or a new widget area.

## Functions.php vs WordPress Plugins

There are a number of advantages and disadvantages to using the functions.php file rather than a WordPress plugin. Here are some of the most notable differences.

### A functions.php file:

* May have many blocks of code used for different purposes
* Does not require single header text
* Stored in theme subdirectory in **wp-content/themes**
* Only runs in the current theme directory.
* Applies only to this theme (and becomes inactive when changing theme).

### A WordPress plugin:

* Requires specific and unique header text
* Stored in **wp-content/plugins** (usually in a specific subdirectory)
* Only runs when loading the page
* Applies to all themes
* Should have only one specific function (for example, offering SEO or caching functions)

### Be careful when using the functions.php file 

If you want to modify your functions.php file, remember to be very careful, for the following reasons: 

* Changes to the function file are lost each time the theme is updated.
* Your changes are also lost if you change your WordPress theme.
* Finally, making coding errors in the functions.php file can make your site inaccessible.

Making a coding error (even as simple as a missing semicolon) could cause the error known as *Blank Screen of the mort* and other errors. If you want to modify the functions.php file, it is strongly recommended to use a child theme. 

The code extracts will only be used with the active child theme. You can then include excerpts from CSS style sheets, custom fonts or a translation tool for this specific child theme.