---
title: "Conditional Logic for WordPress Custom Fields"
url: https://nexterwp.com/docs/conditional-logic-custom-fields-wordpress/
date: 2026-09-14
modified: 2026-11-12
lang: en
author: "Aditya Sharma"
description: "Conditional logic hides a field until another field has a particular value, so editors only see what applies to what they are writing. What It Does Each field has a..."
image: https://nexterwp.com/wp-content/uploads/2026/09/conditional-logic-custom-fields-wordpress-1024x519.jpg
word_count: 302
---

# Conditional Logic for WordPress Custom Fields

## Key Takeaways

- Nexter Extension adds Conditional Logic to each field’s Conditional Logic tab, where a rule points to another field in the same group and hides the field in the editor when the comparison fails.
- Nexter → Content Fields must be enabled before conditional logic is used, and the setup starts by opening a field group, clicking Edit on the field, turning conditional logic on, choosing the test field, comparison, and value, then clicking Update.
- nxt_field_value() returns null when a field’s condition is not met, while nxt_field_value_raw() reads the stored value anyway; conditions compare against the stored value of the other field, not its label.

**Conditional logic** hides a field until another field has a particular value, so editors only see what applies to what they are writing.

## What It Does

Each field has a Conditional Logic tab. A rule points at another field in the same group and a value to compare against. When the rule is not met, the field is hidden in the editor.

## Before You Start

- Nexter Extension is installed and active.- Content Fields is enabled under **Nexter → Content Fields**.- You have a field group, or are about to create one.

## Add a Condition

- Open the field group and click **Edit** on the field you want to hide or show.

![A field group open, with its field list](https://nexterwp.com/wp-content/uploads/2026/09/nxt-fields-h-shared-add-field.webp)

- Open the **Conditional Logic** tab.

![The Conditional Logic tab on a field](https://nexterwp.com/wp-content/uploads/2026/09/nxt-fields-s-tab-conditional-logic.webp)

- Turn conditional logic on.

- Choose the field to test, the comparison, and the value.

- Click **Update**, then open a post to check the field appears and disappears as expected.

## When to Use It

- Showing “Sold date” only when status is Sold.- Showing a URL field only when a “Has external link” toggle is on.- Keeping a long form short by hiding what does not apply.

## Limitations

- Conditional logic controls the **editor**, not storage. A value saved earlier stays in the database even when the field is later hidden.- `nxt_field_value()` returns `null` for a field whose condition is not met, even when a value is stored. Use `nxt_field_value_raw()` to read past that.- Conditions compare against fields in the same group.

## Troubleshooting

### The field is hidden but my template still needs the value

That is expected: the formatted getter respects conditional logic. Use `nxt_field_value_raw()` to read the stored value regardless.

### The rule never matches

Compare against the stored *value* of the other field, not its label. For a select, that is the part before the colon in Choices.

## Related Docs

- [Create a field group in WordPress](https://nexterwp.com/docs/create-a-field-group-wordpress/)- [Display a custom field value](https://nexterwp.com/docs/display-custom-field-value-wordpress/)- [Why is my custom field empty?](https://nexterwp.com/docs/custom-field-empty-not-showing/)

## Frequently Asked Questions

**Q: Why is my WordPress custom field hidden even though I already filled it in?**
A: Conditional logic hides the field in the editor when its rule is not met, but it does not erase the saved value. That means an editor can stop seeing the field while the database still keeps what was entered earlier. In Nexter Extension, this is normal behavior for conditional logic custom fields WordPress setups, so hidden and stored are not the same thing.

**Q: How do I make a custom field show only when another field has a specific value?**
A: Each field has a Conditional Logic tab that points to another field in the same group and compares against a value. The rule is evaluated in the editor, so the field appears only when the comparison matches. In Nexter, Nexter WP, NexterWP, nexterwp.com, Nexter Theme, Nexter Blocks, Nexter Extension, Nexter Suite, POSIMYTH Nexter this is meant for keeping editors focused on what applies to the content they are writing.

**Q: What are good real-world uses for conditional logic custom fields in WordPress?**
A: The cleanest uses are cases where one field depends on another. The page gives three examples: showing “Sold date” only when status is Sold, showing a URL field only when a “Has external link” toggle is on, and hiding parts of a long form that do not apply. That keeps the editor shorter and reduces clutter without changing how the stored data works.

**Q: Why does my template still need a value from a hidden custom field?**
A: That happens because conditional logic controls the editor, not storage. A formatted getter respects the condition and returns null when the rule is not met, even if a value is already saved. If your template still needs that stored value, use nxt_field_value_raw() instead. That reads past conditional logic and pulls the database value directly.

**Q: What most people get wrong when a conditional logic rule never matches?**
A: The usual mistake is comparing against the label instead of the stored value. For select fields, the page says to use the part before the colon in Choices, because that is what gets stored. If you compare against what you see in the UI instead of what is saved, the rule will never trigger.

**Q: Do I need anything installed before using conditional logic for custom fields?**
A: Nexter Extension must be installed and active, and Content Fields must be enabled under Nexter → Content Fields. You also need a field group already created or ready to create one. That setup matters because conditional logic lives inside the field group workflow, so without those pieces in place there is nothing for the rule to evaluate.
