Saturday, October 24, 2026The WordPress PlaygroundFacebookXPinterest
Glossary

functions.php

Many WordPress tutorials ask you to "paste this code into your theme's functions file." That file is functions.php, a PHP file inside your theme folder that adds features and custom code to your site while that theme is active.

In this guide, we will see what it does and how you can edit it without breaking anything.

What Does functions.php Do?

The functions.php file works a lot like a plugin that comes bundled with your theme. WordPress loads it automatically on every page, both on the front end and in the dashboard. Themes use it to register menus and widget areas, load styles and scripts, and turn on features.

For example, the line add_theme_support( 'post-thumbnails' ); enables featured images. You will find the file at wp-content/themes/your-theme/functions.php.

functions.php vs a Plugin

There is one big difference. Code in functions.php only runs while that theme is active. If you switch themes, the code stops working. So, theme-related tweaks belong here, while features you want to keep forever belong in a plugin.

Also, a child theme's functions.php does not replace the parent's file. WordPress loads both, starting with the child theme.

How to Edit functions.php Safely

  1. First, take a full backup of your site.
  2. Now, create a child theme, so your changes survive theme updates.
  3. Next, open the child theme's functions.php using FTP or your host's file manager.
  4. Here, paste your code at the bottom of the file and save it.
  5. Finally, reload your site and check that everything works.

If you don't have a child theme yet, follow our guide on how to create a child theme in WordPress. I prefer FTP over the dashboard editor here, because I can undo a bad change in seconds.

Warning

A single missing semicolon or bracket in functions.php can take your whole site down. If that happens, our guide on how to fix syntax errors in WordPress will help you recover.

[/notice]

So, treat this file with care, and it will serve your theme well. That's it for today. Feel free to share your doubts in the comment box below.