Writing functions is a necessary skill in developing WordPress plugins. In order to do this, have a code editor, a developer installation of WordPress and a file for your function. Open your file to add a comment to identify your function. Then code inside braces, this includes all conditional tags as well. Later, activate the function by coding it into the theme template file, or attaching an action or filter hook. Avoid wrapping your conditional tags around the action hook. Also, do not wrap your conditional tag around the function.
Key Takeaways:
This function is going to be a simple one to register a couple of Google fonts in my theme.
Format comments so they’re clear and easy to find when quickly scrolling through the file at a later date.
All of the code which you want the function to run goes inside the braces.
“If you’re confident that your plugin should be in the theme functions file and your theme doesn’t already have one, then see our ultimate guide to the functions file.”
Read more: https://premium.wpmudev.org/blog/how-to-write-and-activate-a-function-in-wordpress/