Support Log in

14. Layout Fields (Tab, Accordion, Message)

Developer Guide
Prefer video? Watch the Field Forge tutorials 8 short guides covering every feature Watch

These fields do not store values. They control the admin UI layout and organization.

Field TypePurposeTemplate Code
TabStarts a labelled section in the editor; the fields after it, up to the next Tab or Accordion, appear under its headingNone needed
AccordionStarts a labelled section in the same way; the heading does not collapse anythingNone needed
MessageDisplays a read-only message/instructions in the editorNone needed

Layout fields are configured in the field group definition and affect only the WordPress admin interface. They have no output in templates. Use them to organize complex field groups into logical sections. In the post editor a Tab or an Accordion is a heading with its fields under it: nothing switches and nothing collapses. On an options page none of the three types is shown.

php
// Example: Creating a field group with tabs programmatically
FIELDFORGE_Field_Groups::instance()->create( [
    'title'  => 'Product Details',
    'fields' => [
        // Tab: General
        [ 'key' => 'field_tab_general', 'label' => 'General', 'type' => 'tab' ],
        [ 'key' => 'field_title', 'label' => 'Title', 'name' => 'product_title', 'type' => 'text' ],
        [ 'key' => 'field_desc', 'label' => 'Description', 'name' => 'product_desc', 'type' => 'textarea' ],

        // Tab: Pricing
        [ 'key' => 'field_tab_pricing', 'label' => 'Pricing', 'type' => 'tab' ],
        [ 'key' => 'field_price', 'label' => 'Price', 'name' => 'price', 'type' => 'number' ],
        [ 'key' => 'field_sale', 'label' => 'Sale Price', 'name' => 'sale_price', 'type' => 'number' ],

        // Tab: Media
        [ 'key' => 'field_tab_media', 'label' => 'Media', 'type' => 'tab' ],
        [ 'key' => 'field_gallery', 'label' => 'Gallery', 'name' => 'gallery', 'type' => 'gallery' ],

        // Message field for instructions
        [ 'key' => 'field_msg', 'label' => 'Note', 'type' => 'message', 'message' => 'Upload at least 3 product images.' ],
    ],
    'location_rules' => [
        [ [ 'param' => 'post_type', 'operator' => '==', 'value' => 'product' ] ],
    ],
] );

—

Forge AI Assistant Online

Hi! I'm the Field Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs