I am a developer but a new to WordPress. I want to do some custom development. As far as I know I have three options to so so:
1. Functions.php
2. Code snippet plugin
3. Create my own plugin
Am I correct that these are the available options?
My intention would be to create one, custom, plugin in order to customize my environment. In this way I am flexible and independent. Would you agree?
If the customization is simple and you are using a child theme, functions.php is the way to go as you won’t bother the hassle of creating a plugin.
If the customization might break the site or you don’t use a child theme, a plugin is the way to go. You can create a single plugin with a php file, write it and then, if something goes wrong you simply disable the plugin or rename/delete the folder.
My general rule of thumb is this:
If the custom functionality is meant to modify the theme, use functions.php of a child theme to do it.
If the functionality is either irrelevant to the theme (e.g add blocks etc) then it should be a plugin.
Of course, there are other factors at play like complexity and code distribution, but those are the general, high-level guidelines for me…
Create your own plugin, unless the changes are related to a theme, in which case a child theme with codes in functions.php.
Why?
* Changes remain even when you switch themes
* Easy to create, simply create a php file with the plugin headers / information, and them insert your codes.
If you want, the ready plugin option is good too.
Avoid making changes in any plugin or theme files. You lose it on updates.