I have inserted this code in the functions.php
function shortcode_acf_tablefield( $atts ) {
$a = shortcode_atts( array(
'table-class' => '',
'field-name' => false,
'post-id' => false,
), $atts );
$table = get_field( $a['field-name'], $a['post-id'] );
$return = '';
if ( $table ) {
$return .= '<table class="super-table ' . $a['table-class'] . '" border="0">';
if ( ! empty( $table['caption'] ) ) {
echo '<div class="titolo-tabella">' . $table['caption'] . '</div>';
}
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 .= do_shortcode( $td['c'] );
$return .= '</td>';
}
$return .= '</tr>';
}
$return .= '</tbody>';
$return .= '</table>';
}
return $return;
}
add_shortcode( 'table', 'shortcode_acf_tablefield' );
Then I created a custom post type where I just create a table and with this shortcode:
[table field-name=”super_table” post-id=”9″ table-class=”my-table”]
I output the table where I want.
Now I want to create a new custom field so that it can be used together with the table. For example a new title or a new image in addition to the caption
Is that cleare? Thank you for your patience