How to Edit functions.php in WordPress

When it comes to customizing a WordPress theme, one of the most important files to be familiar with is the functions.php file. This file plays a crucial role in controlling the functionality and features of a WordPress theme. In this article, we’ll talk about the functions.php file in WordPress. We’ll explain what it does, where you can find it, and why it’s important. Moreover, we’ll learn how to edit functions.php in WordPress using various methods.

What is the functions.php file?

The functions.php file is a crucial component of a WordPress theme. It contains PHP code that adds extra functionality to your website. It acts as a plugin, allowing you to modify various aspects of your site, such as adding custom functions, filters, and actions.

Where is the functions.php file located?

The functions.php file is located within the theme folder of your WordPress installation. To access it, navigate to your active theme’s directory. You can find it by going to wp-content/themes/your-active-theme/.

Why edit the functions.php file?

Editing the functions.php file gives you the flexibility to customize your WordPress site without relying on external plugins. It allows you to add or modify code snippets to enhance your site’s functionality, such as adding custom post types, modifying default behaviors, or integrating third-party APIs.

Remaining cautious when updating functions.php file

While editing the functions.php file can be a helpful, it’s important to exercise caution to avoid potential issues. Here are a few tips to help you stay on the safe side:

  • Backup your functions.php file: Before making any changes, create a backup of the original functions.php file. This ensures that you can easily revert back to the previous version if something goes wrong.
  • Use a child theme: It is highly recommended to use a child theme when editing the functions.php file. This way, you can preserve your modifications even when the parent theme is updated.
  • Test your changes: Always test your code snippets in a development environment before implementing them on your live site. This allows you to identify any potential conflicts or errors.

If you’re not comfortable editing code or are a non-developer, there’s a user-friendly plugin called Code Snippets by Code Snippets Pro. This plugin allows you to add custom code snippets to your active theme without modifying the functions.php file directly. It provides a safe and easy way to extend your site’s functionality.

Code Snippets Plugin to add WordPress functions.

Here’s how to use Code Snippets plugin effectively:

  • Download the plugin from or their website.
  • Upload it to your WordPress plugins directory and activate it.
  • Navigate to Plugins > Code Snippets in your WordPress dashboard.
  • Click Add New.
  • Give your snippet a descriptive name and enter the code you want to add.
  • In the free version, you have the ability to add Custom Functions and HTML Content. In this blog post, we are learning how to edit functions.php in WordPress which means we may want to add a new function. Therefore, please input the code in the functions tab.
  • After adding your code, you can select where you want this function to run.
  • Set the Priority (if relevant) to determine the order in which snippets execute.
  • Click Save Changes.

It’s done!

Remember, even with plugins, understanding the code snippets you use is crucial. So, take some time to familiarize yourself with the basics of PHP and how it interacts with your WordPress theme.

WPNotch Banner
WPNotch Mobile Banner

How to edit functions.php in WordPress?

There are two common methods to edit the functions.php file: via the WordPress default theme editor or via FTP. Let’s explore both options:

WordPress provides a built-in theme file editor that allows you to modify theme files, including the functions.php file. However, this method is not recommended as it can break your website if there is a syntax error in the code

WordPress Default Theme File Editor showing how to edit functions.php in WordPress.

Here’s how you can edit functions.php in WordPress using Theme Editor:

  1. Login to your WordPress admin dashboard.
  2. Navigate to Appearance > Theme Editor.
  3. On the right-hand side, you will see a list of theme files. Locate and click on functions.php.
  4. The functions.php file will open in the code editor. Add or modify the PHP code as needed.
  5. Once you have made the desired changes, click on the “Update File” button to save the changes.

Proceed with caution and ensure you have a backup before making any changes.

WPEngine Business
WPEngine Business Alternate

Method 2: How to Edit functions.php using FTP (e.g., Filezilla)

Using FTP (File Transfer Protocol) is the preferred method for editing the functions.php file. It provides a more secure and reliable way to make changes to your theme files.

We use FileZilla as a file manager to edit our website files.

FileZilla Software

Here’s a step-by-step guide:

  1. Download and install an FTP client like Filezilla.
  2. Connect to your website using the FTP client by entering your FTP credentials (host, username, password, and port).
  3. Navigate to the wp-content/themes/your-theme/ directory.
  4. Locate the functions.php file and download it to your computer.
  5. Select “View/Edit” or “Edit” to open the file in a text editor.
  6. Make the necessary changes to the functions.php file and save it.
  7. Upload the modified functions.php file back to the server, overwriting the existing file.

Done! This is how you can edit functions.php in WordPress using the FTP (FileZilla).

WPNotch Banner
WPNotch Mobile Banner

Important Questions to Address

Can I directly edit functions.php in any theme, or is a child theme required?

While you can edit the functions.php file directly in any theme, it is highly recommended to use a child theme. A child theme inherits the functionality of the parent theme while allowing you to make modifications without affecting the original files. This ensures that your changes are preserved even when the parent theme is updated.

Can I add CSS or JavaScript code in functions.php?

No, you can not add CSS or JavaScript code directly to the functions.php file. Instead, use the appropriate methods provided by WordPress, such as enqueueing scripts and styles using the wp_enqueue_style() and wp_enqueue_script() functions. This ensures proper loading and avoids conflicts with other plugins or themes.

Mistakenly edited functions.php using the theme editor, and now an error has disabled site access. How to recover?

If you encounter an error after editing the functions.php file using the theme editor, and it has disabled access to your site, don’t panic. The best way to recover is by accessing your website’s files via cPanel or FTP. Once you have access, navigate to the theme folder and locate the functions.php file. Remove the code you added or replace the entire file with the backup you created earlier. This will restore your site’s functionality.


In conclusion, editing the functions.php file in WordPress can be a powerful way to customize your website. By following best practices, using a child theme, and remaining cautious when making changes, you can enhance your site’s functionality without compromising its stability. Whether you’re a developer or a non-technical user, there are methods available to safely modify the functions.php file and take full control of your WordPress site.

Discover more from WP Notch

Level up your skills. Get expert tips delivered straight to you. Subscribe!

Continue Reading