Functions and snippets.
WHERE CODE GOES
A child theme's functions file, or a code snippets plugin.
WHY A SNIPPETS PLUGIN IS FREQUENTLY BETTER
Snippets survive theme changes Each can be disabled individually A syntax error can be caught before it takes the site down
That last point matters. A syntax error in a functions file locks you out of the admin.
BEFORE ADDING ANY CODE
Back up Know what the code does Have a way to remove it if the site breaks
IF THE SITE BREAKS AFTER ADDING CODE
Remove it by FTP or File Manager.
Edit the functions file and delete what you added, or deactivate the snippets plugin by renaming its directory.
WHAT NOT TO PASTE
Code from unfamiliar sources Code you do not understand Anything a search result suggested without checking what it does
WHAT TO DOCUMENT
What each snippet does and why.
Undocumented code is removed by the next person because nobody knows what it is for.