Where to put add_action() in WordPress

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.

Related posts

Leave a Reply

1 comment

  1. “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.