Hi
I currently do use the following code in my functions.php (copied from a support ticket here and modified it to output also the table caption:
function shortcode_acf_tablefield( $atts ) {
$a = shortcode_atts( array(
'field-name' => false,
'post-id' => false,
), $atts );
$table = get_field( $a['field-name'], $a['post-id'] );
$return = '';
if ( ! empty( $table['caption'] ) ) {
$return .= '<div class="table-title">' . $table['caption'] . '</div>';
}
if ( $table ) {
$return .= '<table class="product-tables">';
if ( $table['header'] ) {
$return .= '<thead>';
$return .= '<tr>';
foreach ( $table['header'] as $th ) {
$return .= '<th>';
$return .= $th['c'];
$return .= '</th>';
}
$return .= '</tr>';
$return .= '</thead>';
}
$return .= '<tbody>';
foreach ( $table['body'] as $tr ) {
$return .= '<tr>';
foreach ( $tr as $td ) {
$return .= '<td>';
$return .= $td['c'];
$return .= '</td>';
}
$return .= '</tr>';
}
$return .= '</tbody>';
$return .= '</table>';
}
return $return;
}
add_shortcode( 'table', 'shortcode_acf_tablefield' );
The shortcode I am using to render the table is: [table field-name=”my-tablename”]
Thanks very much for you help in advance
Uwe