What Is Functions.php File In WordPress?

The function.php file is also known as theme function file. It is used by WordPress theme to define classes, actions, functions, and filters that to be used by our templates. Function.php file is automatically loaded in the admin bar and front-end pages of a WordPress site.

Your function.php file will be /wp-content/themes/your_theme_name/functions.php

In other words, we can say, it is a type of file in which you can put your all working theme that doesn’t want to relate a template. It is not a code that gives only one type of output related to one content.

This file is found in your theme’s folder. More so each & every theme that is already installed has its own function.php file, but there is only active theme’s file can run its code. In case your theme has not function.php file, so you can easily create it. Simply create a plain text file named function.php and add it to the directory of your theme.

However, a child theme can have their own funcion.php files. These files can be used to build on top or completely replace the one in the parent theme directory.

The WordPress codex describes the functions like this:

Function file is like a WordPress plugin which can add features and functionality to a WordPress site. You can use it as PHP or to call the function. However, it is built-in WordPress for defining a new own function. Through the WordPress theme function, you can also produce the same result by adding code to a WordPress plugin.

Use function.php file whenever you want to add simple functionality in your document. This might include extra features inside it.

Common uses of function.php file

  • In adding theme support
  • Help WordPress to find theme’s translation
  • To register navigation menus for WordPress
  • Adding and removing criteria from a parent theme using a child theme.

How to edit a function.php file

You can access the function.php file in many ways:

By using FTP client or via WordPress

 

Access functions.php By Using FTP Client

  • The very first thing, start the FTP client, then choose “Tools>FireFTP”.
  • Thereafter, click the connect button and give the login credentials to connect your FTP server.  
  • Then go to the function.php file by directory structure which is given below:

[WordPress Root] > wp-content > Themes > [current_theme] > functions.php.

  • Download and edit the file with your choice editor.
  • And finally, update the file to update the theme.

Access functions.php via WordPress Admin

  • The very first – login to your WordPress admin area.
  • Once logged in, go to “Appearance>>Editor” from the sidebar.
  • Thereafter, choose the theme as per your liking to edit from “Select theme to edit” drop-down menu.   
  • Navigate and double click “Themes Functions (function.php)” under “Theme Files”, “Template” section.
  • Finally, click the update file button to “Update File”.


Leave a Reply