Skip to content

Expose a Custom Field to the WordPress REST API

Key Takeaways

  • Nexter registers scalar field values as post meta with REST exposure on, but array and structured types stay off because their shape is not a flat scalar the REST schema can describe.
  • Repeater and Relationship require Nexter Pro Extensions 4.8.0 or later, and on Nexter Extension alone neither type can be added; an existing field of either type stays read-only and is never cleared on save.
  • Registering a custom REST field is the supported workaround for repeater, relationship, or link values, and the example exposes a repeater under the key floorplans for the property post type.
Table of Contents

Simple field values appear in a post’s meta over REST. Structured ones do not, by default. This page covers which is which, and what to do when you need one that is excluded.

Repeater and Relationship require Nexter Pro Extensions 4.8.0 or later. On Nexter Extension alone neither type can be added, and an existing field of either type is locked: the value is kept read-only and is never cleared on save.

What It Does

Nexter registers field values as post meta. Scalar types are registered with REST exposure on; array and structured types are registered with it off, because their shape is not a flat scalar the REST schema can describe.

Before You Start

  • A field group matching the post type you are querying.
  • A post with values saved.
  • Somewhere to add a small amount of PHP, for the workaround.

Get a Value over REST

  1. Request the post: /wp-json/wp/v2/<post-type>/<id>.
  1. Look inside meta for the key _nxt_gf_<group>_<field>.
A field group open in the builder
  1. If the field is a repeater, relationship or link, it will not be there — that is deliberate.
  1. To expose one of those, register your own REST field that reads the value server-side and returns the shape you want.

Display the Value

Exposing a repeater under your own key:

<?php
add_action( 'rest_api_init', function () {
    register_rest_field( 'property', 'floorplans', array(
        'get_callback' => function ( $post ) {
            return nxt_field_value( 'floorplans', $post['id'] );
        },
        'schema' => array(
            'description' => 'Floor plan rows',
            'type'        => 'array',
        ),
    ) );
} );

Limitations

  • Repeater, relationship and link values are not exposed by default. Registering your own REST field is the supported way around that.
  • Registered field meta carries no object_subtype, so a key applies across post types rather than being scoped to one.
  • Exposing a value over REST makes it readable by anyone who can read the post. Do not expose anything that should stay private.

Troubleshooting

My field is missing from the meta object

Either it is a structured type that is not exposed by default, or the post has no value saved. Check the type first.

My registered REST field returns null

nxt_field_value() returns null when conditional logic is unmet. Use nxt_field_value_raw() in the callback if you want the stored value regardless.

Related Docs

Share your Thoughts

Still in Doubt? Let’s Assist You

Have Feedback or Questions?

Join our WordPress Community on Facebook!

Related Frequently Asked Questions

Why is my custom field missing from the WordPress REST API response?

Simple field values are exposed as post meta, but structured values are not exposed by default. In Nexter, scalar types are registered with REST exposure on, while array and structured types are registered with it off because the REST schema cannot describe a non-flat shape. If the key is missing, the first thing to check is whether the field type is one of the excluded ones or whether no value was saved on the post.

How do I expose a repeater field in the WordPress REST API?

Repeater fields need a custom REST field because Nexter does not expose them by default. The pattern is to register your own REST field in `rest_api_init`, read the value server-side, and return the shape you want. The example on the page uses `register_rest_field( 'property', 'floorplans', ... )` with `nxt_field_value( 'floorplans', $post['id'] )`, which keeps the API response under your own key instead of relying on post meta.

What custom fields can I get from `/wp-json/wp/v2//`?

Flat scalar fields are the ones that show up in `meta` under `_nxt_gf__`. Repeater, relationship, and link fields are deliberately excluded from that default response. That split matters because simple values fit the REST meta model, while structured values need a custom field if you want them returned in a usable shape.

What should I use if my registered REST field returns null?

`nxt_field_value()` returns null when conditional logic is not met, so a null response can mean the field is being hidden by conditions rather than missing from storage. If you want the stored value regardless of conditional logic, use `nxt_field_value_raw()` in the callback instead. That distinction matters when debugging because it separates display rules from saved data.

Is it safe to expose custom fields through REST for private data?

Exposing a value over REST makes it readable by anyone who can read the post, so private data should stay out of REST entirely. Nexter’s supported workaround for repeater, relationship, and link values is to register your own REST field, but that does not change who can read it. The practical rule is simple: if a post reader should not see it, do not expose it.

Do repeater and relationship fields work on Nexter Extension alone?

Repeater and Relationship require Nexter Pro Extensions 4.8.0 or later. On Nexter Extension alone, neither type can be added, and an existing field of either type becomes locked: its value stays read-only and is never cleared on save. That means these field types are tied to the Pro Extensions layer, not just basic Nexter Extension behavior.

Last reviewed: November 12, 2026

Related Docs