When adding a custom REST endpoint, where do you put the endpoint function, and where do you put the function registration call?
If you are developing a theme, the proper place to put your code in this case if your theme’s functions.php file. This is the file that is surely going to be run when your website is being accessed. If you are developing a plugin, you can put your code inside a php file (like foo.php) … Read more