The Multi Text field type provides a repeatable interface for collecting multiple text values with add/remove functionality and optional drag-and-drop reordering.
array(
'type' => 'multi_text',
'label' => 'Keywords',
'min' => 1,
'max' => 10,
'counter' => true,
)For Default Field Properties, see Field Types Definition.
Minimum number of items. Users cannot remove items below this count.
Maximum number of items. Users cannot add items beyond this count.
Custom button labels. Supports keys: add, remove, duplicate.
Array of buttons to disable. Options: 'move', 'delete', 'duplicate'.
Whether to display a character counter below each text input.
An array of strings.
'alternative_titles' => array(
'type' => 'multi_text',
'label' => 'Alternative Titles',
'description' => 'Add multiple alternative titles for this content',
),'product_benefits' => array(
'type' => 'multi_text',
'label' => 'Product Benefits',
'description' => 'Add 3-5 benefits of this product',
'min' => 3,
'max' => 5,
),'company_locations' => array(
'type' => 'multi_text',
'label' => 'Company Locations',
'buttons' => array(
'add' => 'Add New Location',
'remove' => 'Remove Location',
),
),$alternative_titles = get_post_meta( get_the_ID(), 'alternative_titles', true );
if ( ! empty( $alternative_titles ) && is_array( $alternative_titles ) ) {
echo '<ul>';
foreach ( $alternative_titles as $title ) {
if ( empty( $title ) ) {
continue;
}
echo '<li>' . esc_html( $title ) . '</li>';
}
echo '</ul>';
}'has_multiple_authors' => array(
'type' => 'toggle',
'id' => 'has_multiple_authors',
'label' => 'Multiple authors?',
),
'coauthor_names' => array(
'type' => 'multi_text',
'label' => 'Co-Author Names',
'conditions' => array(
array( 'field' => 'has_multiple_authors', 'value' => true ),
),
),$f = new \Wpify\CustomFields\FieldFactory();
$f->multi_text(
label: 'Keywords',
min: 1,
max: 10,
counter: true,
);- The stored value is always an array, even if only one text input is provided.
- Empty text inputs are stored as empty strings in the array.
- Items can be reordered by dragging unless the
movebutton is disabled. - The
minandmaxconstraints control how many items the user can add or remove. - Ideal for collecting lists of items such as features, benefits, tags, or alternative names.