Conditional logic lets you show or hide a field based on the current value of another field in the same field group. It works both in the WordPress post editor and on user profile pages.
How It Works
When you configure conditional logic on a field, OneMeta checks the value of a specified sibling field in real time. If the condition is met, the field is shown. If not, it is hidden. The field is still saved when hidden — it is only visually toggled.
Setting Up Conditional Logic
In the field builder, expand the Advanced Settings for any field and enable Conditional Logic. Configure three values:
| Setting | Description |
|---|---|
| Field | The key of the sibling field to watch |
| Operator | The comparison operator |
| Value | The value to compare against |
Supported Operators
| Operator | Description | Example |
|---|---|---|
== | Equal to | Show when layout equals grid |
!= | Not equal to | Show when status is not draft |
contains | Contains text (case-insensitive) | Show when title contains sale |
!contains | Does not contain text (case-insensitive) | Show when tags does not contain hidden |
PHP Export Example
When you export a field group as PHP, conditional logic is included in the exported config:
php
'my_field' => [
'type' => 'text',
'label' => 'Custom Subtitle',
'description' => 'Shown only when layout is set to Hero',
'conditional' => [
'field' => 'layout',
'operator' => '==',
'value' => 'hero',
],
],
Practical Examples
Show a colour picker only when a toggle is on:
php
'brand_color' => [
'type' => 'text',
'label' => 'Brand Colour',
'conditional' => [
'field' => 'use_brand_color',
'operator' => '==',
'value' => '1',
],
],
Hide a field when a select is set to a specific value:
php
'external_url' => [
'type' => 'url',
'label' => 'External Link',
'conditional' => [
'field' => 'link_type',
'operator' => '==',
'value' => 'external',
],
],
Show a field only when a text input is not empty:
php
'subtitle' => [
'type' => 'text',
'label' => 'Subtitle',
'conditional' => [
'field' => 'title',
'operator' => '!=',
'value' => '',
],
],
Notes
- Conditional logic is evaluated in real time in the browser — no page reload required
- A hidden field’s value is not cleared when the field is hidden — it remains saved
- You can only reference fields within the same field group
containsand!containsoperators are case-insensitive- Conditional logic is fully supported inside Repeater sub-fields