Ready to get started?Download WordPress

Plugin Directory

Code Snippets

An easy, clean and simple way to add code snippets to your site.

Further documentation available on the plugin website.

Do I need to include the <?php, <? or ?> tags in my snippet?

No, just copy all the content inside those tags. If you accidentally forget (or just like being lazy), the tags will be stripped from the beginning and end of the snippet when you save it. You can, however, use those tags inside your snippets to start and end HTML sections.

Is there a way to add a snippet but not run it right away?

Yes. Just add it but do not activate it yet.

How can I insert my snippet into the post text editor?

Snippets that you add to this plugin are not meant to be inserted into the text editor. Instead, they are run on your site just as if they were added to your functions.php file.

Where did the Import menu go after upgrading to version 1.6?

As the import menu is not accessed neatly as much as the manage or add new menus, it has been moved under the Tools > Import menu. To access the import page, visit the Tools > Import menu in your WordPress dashboard and click on the Code Snippets link.

Help! I just activated a snippet, and my whole site broke!

You can try activating 'safe mode'. All snippets will not execute while safe mode is active, allowing you to access your site and deactivate the snippet that is causing the error. To activate safe mode, add the following line to your wp-config.php file, just before the line that reads /* That's all, stop editing! Happy blogging. */:

define('CODE_SNIPPETS_SAFE_MODE', true);

To turn safe mode off, either comment out this line or delete it.

What do I use to write my snippets?

The CodeMirror source-code editor will add line numbers, syntax highlighting, bracket matching, search, tabulate and other cool features to the code editor.

Can I preform search and replace commands in the code editor?

  • Ctrl-F / Cmd-F : Start searching
  • Ctrl-G / Cmd-G : Find next
  • Shift-Ctrl-G / Shift-Cmd-G : Find previous
  • Shift-Ctrl-F / Cmd-Option-F : Replace
  • Shift-Ctrl-R / Shift-Cmd-Option-F : Replace all

Will I lose my snippets if I change the theme or upgrade WordPress?

No, the snippets are added to the WordPress database so are independent of the theme and unaffected by WordPress upgrades.

Can the plugin be completely uninstalled?

Yes, when you delete Code Snippets using the 'Plugins' menu in WordPress it will clean up the database table and a few other bits of data. Be careful not to remove Code Snippets using the Plugins menu unless you want this to happen.

Can I copy any snippets I've created to another WordPress site?

Yes! You can individually export a single snippet using the link below the snippet name on the 'Manage Snippets' page or bulk export multiple snippets using the 'Bulk Actions' feature. Snippets can later be imported using the 'Import Snippets' page by uploading the export file.

Can I export my snippets to PHP for a site where I'm not using the Code Snippets plugin?

Yes. Click the checkboxes next to the snippets you want to export, and then choose Export to PHP from the Bulk Actions menu and click Apply. The generated PHP file will contain the exported snippets' code, as well as their name and description in comments.

Can I run network-wide snippets on a multisite installation?

You can run snippets across an entire multisite network by Network Activating Code Snippets through the Network Dashboard. You can also activate Code Snippets just on the main site, and then individually on other sites of your choice.

Is there anyway to add categories to snippets?

Users of Code Snippets version 1.7 and later can install the Code Snippets Tags plugin for the ability to add tags to snippets, and then later filter the snippets by tag for easier organization.

I need help with Code Snippets

You can get help with Code Snippets either on the WordPress Support Forums, on GithHub, or on WordPress Answers.

I have an idea for a cool feature for Code Snippets!

That's great! Let me know by starting (or adding to) a topic in the Support Forums or open an issue on GitHub.

I want to contribute to and help develop the Code Snippets plugin!

That's fantastic! Join me on GitHub, and also be sure to check out the development page on the project website.

Requires: 3.3 or higher
Compatible up to: 3.9.1
Last Updated: 2014-5-8
Downloads: 39,535


4 stars
4.7 out of 5 stars


0 of 2 support threads in the last two months have been resolved.

Got something to say? Need help?


Not enough data

2 people say it works.
0 people say it's broken.

100,1,1 100,1,1
100,2,2 100,2,2
100,1,1 67,3,2 100,1,1 100,3,3 100,3,3 100,6,6 100,1,1
25,4,1 100,1,1 100,2,2
75,4,3 67,3,2 100,1,1