Where to put add_action() in WordPress

wordpress, wordpress-theming

Solution

"functions.php" is the file where you want to put your custom functions, hooks and actions. If your theme doesn't have a functions.php just create it. Wordpress will get the contents of it automatically, so you will have access to defined functions anywhere in your theme.

Problem

I am new to WordPress. I was referring to code of WordPress theme. I am confused about where to put our function and `add_action()` for that function. I want to know whether it is right to define function and `add_action` in one PHP file and put it anywhere in our theme folder.

Original source