Skip to main content

Key Value

The key-value field allows you to enter an unlimited group of "key-value" pairs. It's usually used for a list of items, such as a product specification.



Besides the common settings, this field has the following specific settings, the keys are for use with code:

PlaceholderplaceholderArray of placeholder texts for key and value inputs. Format ['key' => 'Key placeholder', 'value' => 'Value placeholder']. Optional.

This is a sample field settings array when creating this field with code:

'id' => 'key_value',
'name' => 'Key Value',
'type' => 'key_value',
'desc' => 'Add more additional info below:',


This field saves a serialized array of data of pairs in a single row in the database.

Template usage

Displaying list of key-value pairs:

<?php $pairs = rwmb_meta( 'my_field_id' ) ?>
<?php foreach ( $pairs as $pair ) : ?>
<li><label><?= $pair[0] ?>:</label> <?= $pair[1] ?></li>
<?php endforeach ?>

or simpler:

<?php rwmb_the_value( 'my_field_id' ) ?>