Back to Community

Where Are Code Snippets Stored? A Guide to Database Management

16 threads Sep 11, 2025 PluginCode snippets

Content

If you use the Code Snippets plugin, you might wonder where your custom code is actually kept. Unlike theme functions or plugin files, snippets aren't stored in your site's file system. This guide explains the plugin's storage system and how to manage your snippets effectively.

Where Snippets Are Stored

All snippets created with the Code Snippets plugin are stored directly in your WordPress database. Specifically, they reside in a dedicated database table named snippets. This design allows for easy management through the WordPress admin interface without requiring file access.

Common Questions and Solutions

1. Why can't I find a physical snippet file?

Since snippets are database entries, you won't find them as physical .php files in your theme or plugin directories. This is normal operation for the plugin. If a caching or optimization plugin (like SG Optimizer) is modifying your HTML output, you'll need to configure that plugin to exclude the database table where snippets are executed, not a file.

2. How can I back up my snippets?

The most reliable method is to use the plugin's Export feature to download your snippets as a .json file. For a more comprehensive backup, you should back up your entire WordPress database, which will include the snippets table. The Code Snippets team has confirmed that your snippets will remain in the database even if you deactivate or uninstall the plugin, but a backup is always recommended.

3. I accidentally deleted a snippet. Can I get it back?

Unfortunately, the plugin does not have a trash or recovery system. Deleting a snippet removes it immediately from the database. Your only recourse is to restore the snippet from a previous database backup or from a .json export file you may have created. A good practice is to use the Clone feature to create a duplicate of important snippets as a safety measure before making significant changes.

4. Can I edit snippets in an external code editor?

Because snippets are stored in the database and not as local files, directly editing them with an external editor like VS Code is not currently supported. The Code Snippets team has indicated that a future version might allow for execution from local files, but the snippet information would likely still be managed in the database. For now, editing must be done within the WordPress admin area.

Key Takeaways

  • Snippets are database entries, not files.
  • Always export and back up your snippets regularly.
  • There is no undo feature for deletions; use the Clone function for safety.
  • Editing is currently confined to the WordPress admin interface.

Understanding this database-centric approach is key to effectively managing your code snippets and troubleshooting related issues.

Related Support Threads Support