---
title: "Display a Custom Field Value in WordPress"
url: https://nexterwp.com/docs/display-custom-field-value-wordpress/
date: 2026-09-14
modified: 2026-11-12
lang: en
author: "Aditya Sharma"
description: "Storing a value is half the job. This page covers getting it back out — in a theme template, in Nexter Blocks, or anywhere else on the front end. What..."
image: https://nexterwp.com/wp-content/uploads/2026/09/display-custom-field-value-wordpress-1024x519.jpg
word_count: 453
---

# Display a Custom Field Value in WordPress

## Key Takeaways

- Nexter Extension provides nxt_field_value(), which returns a field’s value for the current post already formatted to the field’s settings.
- nxt_field_value() accepts a second argument for another post ID, and nxt_field_values() returns every value on the current post keyed by field name.
- Nexter Extension functions exist only while the plugin is active, and nxt_field_value() returns null when conditional logic is not met; use nxt_field_value_raw() for the stored value.

Storing a value is half the job. This page covers getting it back out — in a theme template, in Nexter Blocks, or anywhere else on the front end.

## What It Does

Content Fields provides template functions for reading values. The one you will use most is `nxt_field_value()`, which returns a field’s value for the current post, already formatted according to that field’s settings.

## Before You Start

- A field group with at least one field, saved with a value on a post.- You know the field’s **Field Name** — not its label. The two differ once you edit the label.

## Read a Value in a Template

- Open the template that renders the post — for example `single.php` or a template part.

- Call `nxt_field_value()` with the field name.

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

- Check the value is not empty before rendering it.

- Escape it for the context you are printing into — `esc_html()` for text, `esc_url()` for links, `esc_attr()` for attributes.

## When to Use It

- Rendering field values in a classic theme template.- Reading a value from a different post — pass its ID as the second argument.- Checking whether a value exists before rendering a whole section.

## Display the Value

The common shapes, in one place:

`<?php
// A single value for the current post
$price = nxt_field_value( 'price' );
if ( '' !== $price ) {
echo esc_html( $price );
}

// A value from another post
$ref = nxt_field_value( 'reference', 123 );

// Every value on the current post, keyed by field name
$all = nxt_field_values();

// Does the field exist and have a value?
if ( nxt_has_field( 'brochure' ) ) {
// ...
}

// The unformatted, raw stored value
$raw = nxt_field_value_raw( 'available' );`

## Limitations

- These functions exist only while Nexter Extension is active. Wrap calls in `function_exists()` if your theme must survive the plugin being disabled.- `nxt_field_value()` returns `null` for a field whose conditional logic is not met, even when a value is stored. Use `nxt_field_value_raw()` if you need the stored value regardless.- Values are cached per request. Reading the same field twice in one page load does not hit the database twice.

## Troubleshooting

### The function returns nothing

Check three things, in order: the **Field Name** matches exactly (not the label), the post actually has a value saved, and the field group’s location rules match the post you are reading from.

### I get 0 where I expected an empty value

Some field types store an empty value as `0`. Test with `'' !== $value` rather than `empty()`, which treats `0` as empty.

### Fatal error: call to undefined function

Nexter Extension is not active, or the template runs before plugins load. Guard with `function_exists( 'nxt_field_value' )`.

## Related Docs

- [Create your first field group](https://nexterwp.com/docs/create-a-field-group-wordpress/)- [Why is my custom field empty?](https://nexterwp.com/docs/custom-field-empty-not-showing/)- [Repeater field](https://nexterwp.com/docs/wordpress-repeater-field/)

## Frequently Asked Questions

**Q: Why is my custom field value not showing on the front end?**
A: The usual cause is a mismatch between the Field Name, the saved value, and the post you are reading from. Nexter Extension’s field functions return values for the current post, so if the field name is off by even one character, or the field group location rules do not match that post, nothing prints. A quick sanity check is to confirm the field was saved on that post and that you are using the field name, not the label. See [Why is my custom field empty?](https://nexterwp.com/docs/custom-field-empty-not-showing/).

**Q: How do I display a custom field value in a WordPress template?**
A: Use `nxt_field_value()` inside the template that renders the post, such as `single.php` or a template part. That function returns the current post’s value already formatted according to the field settings, which matters because formatting can change how text, links, or other field types should be printed. The safe pattern is to check for an empty value first and escape it for context with `esc_html()`, `esc_url()`, or `esc_attr()` before outputting it.

**Q: Can I read a custom field from a different WordPress post?**
A: `nxt_field_value()` supports reading from another post by passing its ID as the second argument. That is useful when one template needs to pull reference data from elsewhere instead of only from the current post. The page’s example uses `nxt_field_value( 'reference', 123 )`, so the key detail is that you still pass the field name first and then target post ID second. This keeps template logic predictable when you are building related-content sections.

**Q: What should I use when I need the raw stored custom field value?**
A: `nxt_field_value_raw()` returns the unformatted stored value, which is different from `nxt_field_value()` because it skips field formatting. That matters when conditional logic or downstream code needs the exact saved data rather than a display-ready version. Nexter Extension also notes that `nxt_field_value()` returns `null` when conditional logic is not met, even if a value exists, so raw access is the safer choice when you need storage-level truth.

**Q: What is the best way to check whether a custom field has a value before showing a section?**
A: `nxt_has_field()` is the cleanest check when an entire section depends on a field existing and having content. The page also shows why this matters: some fields can store an empty value as `0`, so using `empty()` can hide valid data by mistake. A stricter comparison like `'' !== $value` avoids that trap and works better when you need to distinguish real zero values from truly empty ones.

**Q: Why does nxt_field_value() return nothing or throw an undefined function error?**
A: Two different problems show up here. If it returns nothing, verify three things in order: the Field Name matches exactly, the post actually has a saved value, and the field group location rules match the post being read. If you get a fatal error for an undefined function, Nexter Extension is either inactive or your template runs before plugins load. In that case, guard calls with `function_exists( 'nxt_field_value' )` so your theme does not break when the plugin is unavailable.
