Guide

Heading Control

PHP Field Configuration Reference

Heading

Use this config when fieldType is heading.

This is a display-only component that renders a heading (h1–h6) inside the meta box. It does not store any meta value.

1) Base Parameters

ParameterRequiredTypeDefaultChoicesDescription
fieldTypeYesstringheadingheadingSets control type.
nameYesstringSets control name. Use snake_case.
fieldLabelYesstringSets control label.

2) Heading Specific Parameters

ParameterRequiredTypeDefaultChoicesDescription
textNostringHeading content text.
levelNoint21, 2, 3, 4, 5, 6The heading level (h1–h6).

3) PHP Array Schema

Here is an example of how to use the heading control in a post meta configuration:

[
    'fieldType' => 'heading',
    'name' => 'post_heading',
    'fieldLabel' => 'Section Heading',
    'text' => 'Design Settings',
    'level' => 2,
]

3) Hook-Based Example (Post Meta Config)

It is available to use this control in post meta fields, term meta fields and user settings page and options page fields.

Available hooks:

  • native_custom_fields_post_meta_fields
  • native_custom_fields_term_meta_fields
  • native_custom_fields_user_meta_fields
  • native_custom_fields_options_page_fields
add_filter( 'native_custom_fields_post_meta_fields', function( array $configs ): array {
    $post_type = 'book';

    if ( ! isset( $configs[ $post_type ] ) || ! is_array( $configs[ $post_type ] ) ) {
        $configs[ $post_type ] = [
            'post_type' => $post_type,
            'sections'  => [],
        ];
    }

    $configs[ $post_type ]['sections'][] = [
        'meta_box_id'       => 'post_options',
        'meta_box_title'    => 'Post Options',
        'meta_box_context'  => 'normal',
        'meta_box_priority' => 'default',
        'fields'            => [
            [
            'fieldType' => 'heading',
            'name' => 'post_heading',
            'fieldLabel' => 'Section Heading',
            'text' => 'Design Settings',
            'level' => 2,
            ],
        ],
    ];

    return $configs;
} );

4) Stored Value Type

Field TypeMeta Value Type
headingN/A (display-only component, no meta value stored)

Was this helpful?