sandywp / plugins / code-snippets
Code Snippets
Manage custom WordPress code in one dashboard. Create PHP and HTML snippets, preview code, track snippet totals and reuse code across sites.
Ready in seconds.
v4.1.0 1,000,000+ installs WP 5.5+ PHP 7.4+

What you get inside
6 screens-
Managing local snippets in table view.
-
Creating a PHP snippet in the code editor.
-
Browsing local snippets in card view.
-
Stats overview with snippet totals and breakdowns.
-
Browsing Community Cloud snippets, with Pro-only items clearly marked.
-
Importing snippet export files with duplicate-handling options.
About this plugin
Code Snippets gives you a dedicated WordPress dashboard for creating, organising and managing custom code. Add PHP functionality and reusable HTML content, choose where PHP snippets run, and activate or deactivate snippets individually.
Find snippets with search, tags and filters, switch between table and card views, and preview code without opening the editor. Lock important snippets to help prevent accidental changes, and use the Stats overview to see snippet totals and breakdowns.
Watch the Code Snippets 4.0 walkthrough
See the plugin in use, including features from both the free and Pro editions. The Pro features listed below require the relevant Pro access.
Want AI-assisted code creation and advanced controls? Code Snippets Pro adds the AI Agent, snippet revisions, visual display conditions, CSS and JavaScript snippets, and connected Cloud workflows.
Your snippets stay separate from your theme files. Browse Community Cloud for shared snippets, and use import and export to reuse your code across sites.
Code Snippets has been available on WordPress.org since 2012 and is active on 1 million+ WordPress installations.
Included in the free plugin
- PHP snippets without editing theme files. Add custom functions and WordPress hooks from your dashboard.
- Reusable HTML content. Create content snippets and insert them into posts and pages with shortcodes.
- Control where PHP runs. Choose everywhere, administration only or front end only. Run-once snippets are available for manually confirmed one-time tasks.
- A built-in code editor. Work with syntax highlighting, code checking and adjustable editor preferences.
- Organised snippet management. Use names, descriptions, tags, search, filters, sorting and bulk actions. Browse in table or card view, preview code without opening the editor, and lock important snippets to help prevent accidental edits or deletion.
- Stats overview. View snippet totals, active and inactive counts, and breakdowns by type, run location and tags.
- Import and export. Move snippets between sites using export files, or export PHP snippets as a PHP file for use without the plugin.
- Community Cloud browsing. Search community-shared snippets from inside WordPress and download supported snippet types.
- Optional file-based execution. Execute supported snippets from generated files instead of evaluating their code from the database.
- Multisite support. Manage network-wide snippets and separate snippets for individual sites.
- Safe Mode and feedback tools. Use Safe Mode to troubleshoot snippet-related failures. An optional feedback reporter can be enabled in settings.
PHP snippets execute code on your site. Only use code you trust, review it before activation and keep a current backup. Safe Mode helps with recovery; it does not make every snippet safe or guarantee that every error can be prevented.
Community-powered Code Snippets Cloud
Browse the community-powered Code Snippets Cloud library from inside WordPress. Search user-shared snippets, preview their code and download snippet types supported by your edition.
A Cloud account is not required to create and run local PHP and HTML snippets. Personal Cloud library, synchronisation and deployment workflows require a connected account and the relevant Pro access.
Code Snippets Pro
Code Snippets Pro extends the free plugin with additional code types, editing tools and connected workflows:
- CSS and JavaScript snippets, with dedicated integration for Gutenberg and Elementor.
- AI Agent. Describe the functionality you need, review and refine a proposed plan, then approve code generation. Review the generated snippets before activating them.
- Snippet revisions. Compare a previous version with the current code and restore an earlier revision.
- Display conditions. Define where and when snippets run through a visual condition editor.
- Form-based Blueprints. Generate PHP code for common tasks such as custom post types, taxonomies, shortcodes, settings pages and extra user profile fields.
- Role-based permissions. Control access to viewing, creating, editing and deleting snippets.
- Ran on this page. See which snippets executed or produced output on the current request through the admin bar.
- Performance and security insights. Optional PHP execution-time tracking and advisory checks for potentially risky code patterns. These checks are not a security audit or a guarantee that code is safe.
- Connected Cloud workflows. Manage your personal Cloud library, synchronise snippets and deploy snippets to connected sites, with drift reporting when site and Cloud copies differ.
Cloud-connected Pro features require the appropriate licence and a connected Code Snippets Cloud account. Local PHP and HTML snippets do not require a Cloud account. The free plugin includes interactive demos of selected Pro workflows; using the full tools requires Pro access.
Documentation and community
- Documentation
- WordPress.org support forum
- Facebook community
- Discord community
- Source code and feature requests
Share your experience
Find Code Snippets useful? Leave a review on WordPress.org to share your experience and help others decide whether the plugin suits their needs.
Translation Credits
Thank you to everyone who helps make Code Snippets available in different languages. See the translation contributors or contribute a translation.
Questions
- How can I recover my site if a snippet causes an error?
Use Code Snippets Safe Mode to prevent snippet execution while you investigate the problem. Follow the Safe Mode instructions for the appropriate recovery method, then fix or deactivate the affected snippet.
- Will I lose my snippets if I change theme or update WordPress?
Snippets are stored separately from your theme in the WordPress database, so changing theme or updating WordPress does not remove them. Code that depends on a particular theme or plugin may still need updating when that dependency changes.
- Can the plugin be completely uninstalled?
Enable Complete Uninstall under Snippets > Settings > Advanced before deleting the plugin through WordPress’s Plugins screen if you want stored snippets and plugin settings removed. Export snippets you want to keep first. Leave Complete Uninstall disabled if you want to retain your snippet data when deleting the plugin.
- Can I copy snippets to another site?
Yes. Export a single snippet or select several snippets and use the export bulk action. Import the resulting file through the Snippets import screen on the other site.
- Can I export snippets to PHP for a site without Code Snippets?
Yes. Select the PHP snippets, choose Export to PHP from the bulk actions and apply it. The generated file contains the exported code, with snippet names and descriptions in comments. Review the file before including it in a theme or plugin.
- Can I run snippets across a multisite network?
Yes. Network activation provides a network-level Snippets screen. Activate a network snippet to run it across the network, subject to its execution scope. Individual sites can also have separate snippets, and shared network snippets can be enabled per site where configured.
- Where are snippets stored in the database?
Local snippets use the site’s table prefix followed by
snippets, for examplewp_snippetson a single site orwp_2_snippetson a subsite. Network snippets use the network’s base prefix followed byms_snippets, for examplewp_ms_snippets. Your actual prefix may differ.When optional file-based execution is enabled, the plugin also creates files used to execute snippets. Continue managing those snippets through the plugin.
- Where can I get help or request a feature?
Use the documentation or WordPress.org support forum for help. Report bugs and suggest improvements on GitHub, or discuss ideas in the Facebook and Discord communities.
sandywp / also on the shelf
Try another plugin
WPCode – Insert Headers and Footers + Custom Code Snippets – WordPress Code…
4.9 · 3M+ installs
Easily add code snippets in WordPress. Insert header & footer scripts, add PHP code snippets with conditional logic, insert…
5.0 · 100K+ installs
Easy add site-wide, category and article specific custom code before the closing </head> and </body>, or after…
4.7 · 100K+ installs
Add Custom CSS to your WordPress site without any hassles.
Spin up a real WordPress site in seconds.
Test plugins, build a demo, hand a client a link — then squash it and start again. No local setup, no Docker.