Note: Snippet Conditions features is currently on a private beta. Make sure to opt-in for beta releases if you want to test it when it goes public.
Snippet Conditions is a new feature that allows you to apply conditional logic to your snippets. For example, you might want a snippet to execute on specific pages, for specific users, or under any other condition. Snippet Conditions allow you to do just that.
Conditional logic overview
In Code Snippets, we have approached Snippets in a different way, aiming for optimized flexibility and maintainability. Here are some foundational concepts.
Conditions are saved as separate entities
Just like any other of your Code Snippets, conditions are saved as separate entities. You can give your conditions a specific name, or just have an auto-generated name. All Conditions show up in your list of snippets, and also in their own dedicated tab.
Conditions can be applied on multiple Snippets
Instead of applying a condition to a specific snippet, you have the flexibility to attach a condition to multiple snippets. Lets say you create a condition that executes a snippet only for your blog posts, and only for logged-in users. You can re-use the same condition on multiple snippets that meet the same conditional criteria.
Creating a condition
There are two ways to create a condition:
- Create a condition from a Code Snippet page
- Create a Condition from the Conditions panel
1. Create a condition from a Code Snippet page
You can easily create a condition from any code snippet page. Just click the conditions button, and the conditions popup will open. You then have 2 options: Either create a new condition from scratch, or apply any of your existing saved conditions.
Create a New Condition
Let’s assume that you want to create a new condition. Just add a name for your condition, in order to be easily recognizable for future use, or leave the name field blank for an autogenerated name.
Then you will need to set set the conditional logic below, which is based on AND/OR operators for maximum flexibility. When you have created your condition rules, just hit the “Save Condition” button to save the newly created condition, and then the “Apply Condition” button to apply it to the snippet.

Apply an existing condition
If you have already created any Conditions, you can easily choose to apply them to the snippet, instead of creating a new one. Just click on the “Apply an existing condition” link, and select your saved condition from the dropdown.
2. Create a condition from the Conditions Tab
Apart from the individual snippet pages, you can also create condition entities from the Conditions tab. Just go to the tab and click the “Add new” button. You will then be able to create a new condition.

In order to attach the specific condition to a Code Snippet, just scroll down to the bottom of the page until you find the “Snippets using this Condition” area. You can use the dropdown to locate the Code Snippet, and then click the attach button. Keep in mind that you can attach the condition to multiple snippets using this dropdown.
This area also allows you to easily detach any snippets from the specific condition.

We need your feedback!
We are working hard to optimize the Conditions functionality and we highly appreciate your feedback especially during the beta phase. Feel free to join the Beta Testing program and share your feedback. We look forward to hearing from you!