With Code Snippets, you can say goodbye to a lot of plugins. It will make your website faster and easier to configure. In this Code Snippets tutorial, I show you how to work with Code Snippets.
Get Code Snippets: https://codesnippets.pro/
Library With Code Snippets: http://ferdykorp.com/cloudsnippets
As the name says, with Code Snippets, you add snippets of code to your WordPress website, which fulfill a task that normally would take a plugin to do. So, with 10 code snippets, you can get rid of 10 plugins.
When you use Code Snippets, you can get rid of all your child themes. Code Snippets Pro has a strong focus on saving you time using custom code or CSS.
Save money by buying fewer single-function plugins. Stop manually editing files like functions.php or style.css. You don’t need to be a coder to safely and easily customize your websites. In this tutorial, I will walk you through all the amazing features of Code Snippets and Code Snippets Pro.
Related: Learn more about WordPress
How to use Code Snippets in WordPress (free and Pro)
Do you want to add features to your WordPress website without installing a new plugin for every little thing? With the Code Snippets plugin you add small pieces of code instead. You can add custom PHP, CSS, JavaScript and HTML, and when you update your theme or plugins, your code stays in place. You also do not need a child theme anymore.
In this tutorial I show you a few quick examples, then the free version, importing and exporting, the Pro version, the settings, and content snippets that you can place anywhere with the block editor or Elementor.
Good to know: I recorded this video in 2022, so some screens, plans and prices of Code Snippets may look different today. The way snippets work is still the same.
What you can do with Code Snippets
Three examples from the start of the video:
- Google Analytics without a plugin. I deleted a whole plugin that only added a tracking code. Instead I made a script snippet, pasted the code, set it to load in the head section, added the tag “analytics” and activated it.
- Custom CSS that survives theme updates. I had changed my styling in the theme CSS file, and after a theme update it was gone. With a CSS snippet the styling stays, even after updates.
- Turn off comments. A PHP snippet removes comments on all blog posts. Want comments back? Just switch the snippet off.
Step 1: install the free version
Go to Plugins, Add New, search for Code Snippets, install and activate it. You now have a Snippets menu with All Snippets, Add New, Import and Settings. A few example snippets are already there. The color shows the type: green is HTML, purple is CSS and blue is PHP. JavaScript snippets are only in Pro.
To add a snippet:
- Click Add New and choose the type, for example a functions (PHP) snippet.
- Give it a clear title and paste the code.
- Choose where it runs, for example everywhere or only on the front end.
- Optionally add a description and tags.
- Click Save changes and activate.
In the video I add a snippet that lets users log in with their email address instead of their username. Handy when people forget their username years later. The included “current year” snippet gives you a shortcode, so a title like “Best WordPress themes of” always shows the current year.
Where do you find snippets? Search for things like “best WordPress code snippets” or “code snippets for WooCommerce”. WooCommerce is quite basic, and many extra features can be added with a snippet instead of a plugin that slows down your site.
Step 2: export and import snippets
- Open a snippet and download it as a PHP file, or export it as a JSON file.
- To move several at once, select them in All Snippets and choose Bulk actions, Export. You get one JSON file with all of them.
- On the other website go to Snippets, Import. Choose what happens with duplicates. I like “do not import any duplicates”. Upload the file.
- Imported snippets are not active yet, so turn them on.
Step 3: what Code Snippets Pro adds
Pro adds CSS and JavaScript snippets, a block and an Elementor widget to show source code on your site, content snippets, and cloud storage with community snippets that people can vote on. In the video there were yearly and lifetime plans in small, medium and large sizes, with a 14 day money back guarantee. I took the large lifetime plan so I can use it on many websites. After buying you download the plugin, upload it under Plugins, Add New, Upload Plugin, and activate your license key.
Examples with Pro from the video:
- A ConvertKit popup script that only runs on the homepage, by using the post ID of that page.
- Related posts shown halfway through a blog post, after a set number of paragraphs.
- A custom scrollbar with a CSS snippet, where I adjusted the width, color and border radius.
- An evergreen countdown: a JavaScript snippet plus an HTML snippet that sets the time, for example 24 hours.
Step 4: content snippets in the editor and Elementor
Normal snippets work on your whole website. Content snippets you place exactly where you want them. A content snippet is HTML, but it can contain PHP, CSS and JavaScript too.
- Create a new content snippet, for example “Last updated blog post”. If it contains PHP, start it with PHP tags.
- Add a tag and press Enter or a comma, otherwise the tag is not saved.
- In the block editor add the Content Snippet block, or in Elementor the content snippet widget, and select your snippet.
- Turn on Run PHP code, otherwise the code is shown as text instead of running.
Now you can style it with the editor, like centering or a background. And if you change the snippet once, it updates on every page that uses it.
The settings I use
- Activate new snippets by default, so saving also activates them.
- Enable tags and descriptions to keep your list organized. I sort the list from A to Z.
- Keep “remove all data on uninstall” off, so you do not lose your snippets.
- In Pro, minify CSS and JavaScript output. I see no reason to turn that off.
- In the code editor I like line numbers, highlighting the active line and an editor that grows with long code.
Frequently asked questions
Is Code Snippets free?
Yes. The free version lets you add PHP, CSS and HTML snippets. Pro adds JavaScript snippets, content snippets in your editor, cloud snippets and more.
Do I still need a child theme?
For custom code and CSS, no. Snippets stay in place when you update your theme, which is the main reason people use a child theme.
Can a snippet break my website?
A wrong piece of code can cause problems, so only use snippets from sources you trust and test after you activate one. The nice thing is that you can switch a snippet off with one click.
Does using snippets make my website faster?
Replacing single feature plugins with small snippets keeps your site lighter. For more speed tips, see the speed up your website prompt. For an older look at the plugin, there is also my first Code Snippets tutorial.



I need it
Hi there i really appreciate your work. Please i need it thanks
Hi Stephanie! Thanks so much ???? Not sure exactly what you need – feel free to describe it in more detail and I’ll do my best to point you in the right direction!
Hi Stephanie! Thanks so much ???? Not sure exactly what you need – feel free to describe it in more detail and I’ll do my best to point you in the right direction!