Skip to main content

Install a snippet

Every snippet page lists a Type and a Status. The type decides where the file goes; the status decides whether you should trust it.

TypeWhere it goesNotes
mu-pluginwp-content/mu-plugins/Always loaded, cannot be deactivated from the admin. Create the folder if it does not exist.
pluginwp-content/plugins/<snippet-name>/Give it its own folder and keep the file name as published.
snippetWP Codebox, Code Snippets, or any snippet managerPaste the file contents without the opening <?php.
scriptWherever you include it fromA plain PHP file, not a WordPress entry point on its own.

Steps​

  1. Open the snippet page and use the Source link to download the .php file.
  2. Copy the file to the location above for its type.
  3. Check the header for site-specific values you must change, such as Author URI or a log path.
  4. Read the Status row: Complete means the snippet was verified on a live site, WIP and Unknown mean try it on staging first.

Removing a snippet​

Delete the file. Every snippet gates itself with the usual defined( 'ABSPATH' ) or die() guard, so nothing else is left behind. Snippets that write log files can leave those behind in the uploads directory or the mu-plugins directory - delete them too.