Skip to content

nxt_group_definitions() — List Field Groups in Code

Key Takeaways

  • nxt_group_definitions() returns every field group registered on the site, including each group key, title, fields, and location rules.
  • Nexter Extension is active and at least one field group exists before nxt_group_definitions() runs.
  • Results are cached per request behind the model cache, and stale definitions may require clearing nxt_model_cache and nxt_ct_definitions_v1 in that order.
Table of Contents

nxt_group_definitions() returns every field group registered on the site, with its fields and its location rules. It is how you build something that adapts to whatever groups exist.

What It Does

Each entry carries the group key, its title, its fields and its rules. It is the same data the admin screen reads.

Before You Start

  • Nexter Extension is active.
  • At least one field group exists.

Iterate the Groups

  1. Call nxt_group_definitions().
The Group Fields tab, listing the groups this function returns
  1. Loop the result; each entry is one group.
  1. Read key, title and fields from each.
  1. Use nxt_group_definition() if you want one specific group by key.

Display the Value

Listing every group and its fields:

<?php
foreach ( nxt_group_definitions() as $group ) {
    printf( '<h3>%s</h3>', esc_html( $group['title'] ) );

    foreach ( $group['fields'] as $field ) {
        printf( '<li>%s (%s)</li>',
            esc_html( $field['label'] ),
            esc_html( $field['type'] ) );
    }
}

Limitations

  • Returns definitions, not values. To read a value, use nxt_field_value().
  • Results are cached per request and behind the model cache. A definition changed on disk outside the admin may be served stale — see the cache troubleshooting doc.
  • This is a read surface. Creating or changing groups goes through the admin or the Content Fields REST routes.

Troubleshooting

A group I just created on the server is missing

The model cache is stale. Clear nxt_model_cache and nxt_ct_definitions_v1 — both, in that order.

I get groups that do not apply to my post

This function returns every group on the site. Filter by location rules yourself, or read values, which already respect them.

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 nxt_group_definitions() returning groups that don't apply to my post?

nxt_group_definitions() returns every field group on the site, not just the ones that match the current post. That is useful when you need a full inventory of groups, but it also means location rules are included as data rather than enforced for you. If you only want post-specific output, filter by the location rules yourself or use values that already respect them.

How do I list all field groups and their fields in code?

nxt_group_definitions() gives you the full set of registered field groups, including each group key, title, fields, and location rules. The page shows a simple loop over the result, then a nested loop over each group’s fields. That pattern is useful when your output needs to adapt to whatever groups exist instead of hardcoding field names.

What is the difference between nxt_group_definitions() and nxt_group_definition()?

nxt_group_definitions() returns every field group registered on the site, while nxt_group_definition() is for one specific group by key. That split matters when you are building a dynamic screen versus targeting a known group. Use the plural form when you need to iterate everything, and the singular form when you already know the exact group key.

Why am I seeing stale field group data after changing a group on disk?

The result can be stale because definitions are cached per request and behind the model cache. The page calls out that a definition changed on disk outside the admin may still be served from cache. In that case, clear nxt_model_cache and nxt_ct_definitions_v1 in that order so the newer definition can surface.

What do I need before using nxt_group_definitions()?

Nexter Extension has to be active, and at least one field group must already exist. Without those two pieces, there is nothing for nxt_group_definitions() to return. That matters because this function reads registered definitions only, so it depends on both the extension being available and actual groups being present.

Can I use nxt_group_definitions() to read field values?

nxt_group_definitions() is for definitions, not values. It returns metadata like the group title, fields, and location rules, which is useful for building adaptive output or admin-style listings. When you need the actual stored value for a field, use Display a custom field value or nxt_field_value().

Last reviewed: November 12, 2026

Related Docs