Tutorials often say "add this code to your theme's functions.php". This guide shows you a safer way to add a PHP snippet: the free Code Snippets plugin, which keeps your code apart from the theme, lets you switch each snippet on and off, and has a safe mode for when a snippet breaks the site. It is written for a Noiz client on any shared plan.
Last reviewed: 19 October 2026, against the current WordPress release. This guide is written for Noiz hosting and is kept current against WordPress. It complements, and does not replace, the official WordPress documentation linked below.
The theme's functions.php is replaced whenever the theme updates, so your code disappears. The built-in Theme File Editor keeps no backup copy, and one typing error there can take the whole site down, editor included. A snippet plugin avoids both: the code lives in the database, survives theme updates, and can be switched off without touching a file.
wp-config.php with Files if you need safe mode.Go to Plugins > Add New Plugin, search for Code Snippets, then install and activate it. A Snippets menu appears.
<?php line if the tutorial includes one.Open your site in a private browser window and check the home page, a post and anything the snippet should change. Then check the dashboard still works. To undo, go to Snippets, find the snippet and select Deactivate.
wp-config.php.define( 'CODE_SNIPPETS_SAFE_MODE', true );
wp-config.php.If you can still reach the dashboard as an administrator, adding ?snippets-safe-mode=1 to a dashboard address also switches snippets off, without editing a file. The recovery link WordPress emails to the admin address is a third way in.
Once your code lives in Code Snippets, nobody needs the built-in file editors. Turn them off by adding this line to wp-config.php with Files:
define( 'DISALLOW_FILE_EDIT', true );
If you keep code in files and version control, put it in a single PHP file in wp-content/mu-plugins. WordPress loads it automatically, and it cannot be switched off from the dashboard, which also means a mistake can only be fixed through the file. For styling changes and child themes, see How to Safely Edit Your WordPress Theme.
WordPress Care keeps WordPress and your plugins updated with a restore point first, so a plugin update that clashes with your snippet can be rolled back. Writing or changing custom code is quoted separately.