How to Edit functions.php File in WordPress?

You WordPress theme does lot of functions to arrange the layout both in the frontend and backend. For example, theme needs to define a function for supporting wide and full width images offered in Gutenberg editor. Otherwise, this function will not work on your site. All theme’s functions are stored in functions.php file which is a basis for your site to work properly. Here we will explain how to edit functions.php file in WordPress site for various reasons.

Why to Edit functions.php File?

Whenever you want to add additional functionalities to your theme, it is necessary to add relevant code in functions.php file. Here are some of the reasons you may need to edit the file:

  • You want to dequeue certain files loaded on your site.
  • Register additional thumbnail sizes on your site.
  • Change the visibility of meta boxes to custom post types offered by your theme.

Where to Find functions.php File?

You can find functions.php file in your theme’s folder. Remember, it comes with your theme and not part of core WordPress files like wp-config.php. It should be in the folder “/wp-content/themes/your-theme/”. Since each theme contains its own functions file any modification you do on the file will be applied only to that particular theme.

How to Edit functions.php File?

  1. Login to your WordPress admin panel and navigate to “Appearance > Theme Editor” section. When you are in Theme Editor, WordPress will show you a warning message not to edit theme files. As mentioned, use child theme for editing the files.
  2. Select your active theme from the dropdown. In our example, we select Twenty Twenty. Make sure to select your active theme.
  3. Find and click on “functions.php” file from the “Theme Files” right sidebar.
  4. Add your functions at the end of the file.
  5. Click “Update File” button to save the changes.
Edit functions.php File
Edit functions.php File

FTP and File Manager

If you use security plugins, Theme Editor will be disabled in the admin dashboard for security reasons. In this case, you will not find the Theme Editor menu item under “Appearance” section. You can use FTP or File Manager app in your hosting account to browser and edit functions.php file. You need to find the file under “/public_html/wp-content/themes/your-theme/” folder.

If you installed WordPress in subdomain or subdirectory then try to find the file under “/public_html/directory/wp-content/themes/your-theme/”.

Using Child Theme and Plugins

The changes you make in functions.php file will be deleted every time when you update the theme’s version. In order to keep the changes permanently, you can use a child theme for adding new functions in functions.php file. In addition, you can also easily use plugins like Code Snippets to add new functions. However, it works only when you want to add new functions and not when you want to edit something in your existing functions.php file.

Leave a Comment