---
title: "Check Whether a Custom Field Exists or Has a Value"
url: https://nexterwp.com/docs/check-custom-field-exists-wordpress/
date: 2026-09-14
modified: 2026-11-12
lang: en
author: "Aditya Sharma"
description: "Three functions answer three different questions, and mixing them up is a common source of confusing template behaviour. What It Does nxt_field_exists() asks whether the field is registered for this..."
image: https://nexterwp.com/wp-content/uploads/2026/09/check-custom-field-exists-wordpress-1024x519.jpg
word_count: 315
---

# Check Whether a Custom Field Exists or Has a Value

## Key Takeaways

- nxt_field_exists() checks whether a field is registered for an object, while nxt_has_field() checks whether it also holds a value and nxt_is_field_empty() checks whether that value is empty.
- Nexter Extension is active before these checks are used, and the field’s Field Name plus the template or plugin context are required.
- Never use empty() on a raw value because it treats 0 as empty; nxt_is_field_empty() handles type-aware emptiness, and a hidden field by conditional logic reads as absent.

Three functions answer three different questions, and mixing them up is a common source of confusing template behaviour.

## What It Does

`nxt_field_exists()` asks whether the field is registered for this object at all. `nxt_has_field()` asks whether it also holds a value. `nxt_is_field_empty()` asks whether the value is empty.

## Before You Start

- Nexter Extension is active.- You know the field’s **Field Name**.- You are editing a template or a plugin.

## Pick the Right Check

- Debugging a template that returns nothing → `nxt_field_exists()`. If it is false, the problem is the field name or the location rules, not the data.

![The Field Name box in the builder](https://nexterwp.com/wp-content/uploads/2026/09/nxt-fields-s-field-name-vs-label.webp)

- Deciding whether to render a section → `nxt_has_field()`.

- Testing the value itself → `nxt_is_field_empty()`, which understands each type’s idea of empty.

- Never use `empty()` on a raw value. It treats `0` as empty, and `0` is a real number.

## Display the Value

The three, in the order you would reach for them:

`<?php
// is it registered here at all?
if ( ! nxt_field_exists( 'price' ) ) {
// wrong field name, or the group does not apply to this post
}

// registered and holding a value?
if ( nxt_has_field( 'brochure' ) ) {
// render the download section
}

// type-aware emptiness
if ( ! nxt_is_field_empty( 'amenities' ) ) {
// render the list
}`

## Limitations

- All three respect conditional logic, so a field hidden by a condition reads as absent.- `nxt_field_exists()` is about registration, not storage. It can be true while no value is saved.

## Troubleshooting

### exists() is true but has_field() is false

The field is registered and simply has no value on this object. That is a content problem, not a code one.

### exists() is false

Either the name is wrong, or no matching field group applies to this object. Check the Field Name in the builder and the group’s location rules.

## Related Docs

- [Template functions reference](https://nexterwp.com/docs/nexter-fields-template-functions/)- [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 does my custom field return nothing even though I know it exists?**
A: That usually means the field is registered, but the current object does not have a saved value. In Nexter, `nxt_field_exists()` checks registration, while `nxt_has_field()` checks whether data is actually present. If `nxt_field_exists()` is true and `nxt_has_field()` is false, the issue is content, not the template logic. That distinction matters when a section should only render when real data exists.

**Q: What’s the best way to decide whether to show a section based on a custom field?**
A: `nxt_has_field()` is the right check when the goal is conditional rendering. It tells you whether the field has a value on that object, which is what you want before outputting a download block, price area, or any other section that should disappear when empty. In Nexter Extension, this avoids showing empty wrappers that make templates look broken.

**Q: How do I check if a WordPress custom field is registered for the current post?**
A: `nxt_field_exists()` is the registration check. It answers whether the field exists for that object at all, which makes it useful when debugging a template that returns nothing. If it comes back false, look at the field name or the location rules instead of chasing the saved data. That saves time because the problem is often placement, not content.

**Q: What’s wrong with using empty() on WordPress custom fields?**
A: `empty()` is too blunt for raw values because it treats `0` as empty, and `0` can be a real value. Nexter’s `nxt_is_field_empty()` is type-aware, so it understands each field type’s idea of empty instead of flattening everything into one rule. That matters for numeric fields where zero should still count as meaningful data.

**Q: Does conditional logic affect whether a custom field looks like it exists?**
A: Conditional logic can make a field read as absent even when it is defined in the builder. All three Nexter checks respect conditional logic, so a hidden field will not behave like an available one on that object. That’s why `nxt_field_exists()` can be true in one context and false in another if the group does not apply.

**Q: What should I check first when `exists()` is false in Nexter?**
A: Start with the Field Name and the group’s location rules. In Nexter WP, `exists()` being false usually means either the name is wrong or no matching field group applies to that object. The fastest fix is to verify both sides: the exact builder name and whether the template context actually matches the group location rules.
