Voxel 1.3.4 is now available

Conditional fields

Conditional fields allow you to create more dynamic and personalized submission forms for your post types. By showing or hiding fields based on user input or other factors, conditional fields can streamline the process and improve the user experience.

For example, consider a form for event registration. If the user selects “Yes” for a checkbox indicating they are bringing a guest, a conditional field may appear asking for the guest’s name. If the user selects “No,” the field would remain hidden. This allows the form to adapt to the user’s choices and display only the relevant fields.

Conditional fields can be particularly useful when dealing with complex forms or content structures where displaying all fields at once would overwhelm the user or create unnecessary clutter. By presenting fields dynamically, based on user actions or specific conditions, conditional fields help simplify the interaction and make the form or content more intuitive and focused.

How to create conditional logic

In the Fields tab of the post type editor, you can configure the fields available for your post type.

Once a field is added, you can enable conditional logic for it.

To activate conditional logic for a specific field, click on that field. In the field popup, open the “Conditional logic” tab and turn on the option “Enable conditional logic for this field?”

By default, there’s a Rule group automatically created and you can add conditions to it.

Each rule group can contain one or more conditions, and you can create additional rule groups if you need.

Conditions within the same group use “And” logic, while different rule groups use “Or” logic.

So basically, within the same rule group, all conditions must be met. If at least one condition is not met in one rule group, the evaluation will continue to the next rule group

When adding a condition, the first option is to select another post type field that you want the current field to be conditioned by.

Next, select the condition. Available conditions include:

  • Is empty
  • Is not empty
  • Equals
  • Not equals
  • Greater than
  • Greater than or equal to
  • Less than
  • Less than or equal to

Depending on the condition selected, additional options may appear. For example, if you choose “Less than,” a number input may appear to specify the value.

Let’s consider an example:

Suppose you are configuring a Tours post type, and depending on whether the tour has a guide or not, you want to display a field to specify the guide’s language.

You can create a switcher field named “Guide language” and a text field named “Specify language.”

In this case, you apply conditional logic to the text field by clicking on the field and enabling condition logic.

Select Source: Guide language
Condition: Is true.

On the post submission form, depending on whether the user has enabled the Guide language switcher, the Specify language field will either appear or not appear.