Table
A lightweight in-admin table editor. Editors add and remove rows and columns, drag rows to reorder, and optionally designate the first row as a header. Data is stored as JSON and returned as a structured PHP array.
Settings
| Setting | Default | Description |
|---|---|---|
| Use Header Row | true | When enabled, the first row is treated as a header and returned under the header key. |
Return values
With header row enabled
$table = get_field('pricing_table');
// [
// 'header' => ['Plan', 'Price', 'Users'],
// 'body' => [
// ['Starter', '$9/mo', '1'],
// ['Pro', '$29/mo', '10'],
// ['Enterprise', '$99/mo', 'Unlimited'],
// ],
// ]
With header row disabled
$table = get_field('schedule');
// [
// 'header' => [],
// 'body' => [
// ['09:00', 'Registration'],
// ['10:00', 'Keynote'],
// ['12:00', 'Lunch'],
// ],
// ]
Usage
Rendering an HTML table
$table = get_field('comparison_table');
if ($table && !empty($table['body'])) {
echo '<table class="data-table">';
if (!empty($table['header'])) {
echo '<thead><tr>';
foreach ($table['header'] as $heading) {
echo '<th>' . esc_html($heading) . '</th>';
}
echo '</tr></thead>';
}
echo '<tbody>';
foreach ($table['body'] as $row) {
echo '<tr>';
foreach ($row as $cell) {
echo '<td>' . esc_html($cell) . '</td>';
}
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
}
Accessing specific cells
$table = get_field('schedule');
if ($table) {
$first_row = $table['body'][0] ?? [];
$first_cell = $first_row[0] ?? '';
echo esc_html($first_cell); // "09:00"
}
Using headers as column keys
$table = get_field('product_specs');
if ($table && $table['header'] && $table['body']) {
$headers = $table['header'];
$rows = [];
foreach ($table['body'] as $row) {
$rows[] = array_combine($headers, $row);
}
// Now access by column name
foreach ($rows as $row) {
echo $row['Price'] ?? '';
}
}
Pro features
The Pro version adds min/max row limits, rich text (TinyMCE) cells, column width control, and CSV import/export.