Using table within Group field type
-
I am trying to use Advanced Custom Fields: Table Field within a Group field type. To show other group items i am using this:
// vars $zone_4 = get_field('zone_4'); if( $zone_4 ): ?> <div id="zone_4" style="margin: 0 -9999rem; padding: 0.25rem 9999rem; background: url(<?php echo $zone_4['background_image']; ?>); background-repeat: no repeat; background-attachment: fixed; background-position: center; background-repeat: no-repeat; background-size: cover; height: 432px; overflow: hidden;"> <div style="text-align:center;"><img src="<?php echo $zone_4['image']; ?>" /></div> <h1 style="text-align:center;"><?php echo $zone_4['header']; ?></h1> <div><p><?php echo $zone_4['content']; ?></p></div> <div>
I now want to show the table and I am using:
<?php $table = get_field( 'table' ); if ( $table ) { echo '<table border="0">'; if ( $table['header'] ) { echo '<thead>'; echo '<tr>'; foreach ( $table['header'] as $th ) { echo '<th>'; echo $th['c']; echo '</th>'; } echo '</tr>'; echo '</thead>'; } echo '<tbody>'; foreach ( $table['body'] as $tr ) { echo '<tr>'; foreach ( $tr as $td ) { echo '<td>'; echo $td['c']; echo '</td>'; } echo '</tr>'; } echo '</tbody>'; echo '</table>'; } ?>
zone_4 is the group name and table is the sub-field name (where I am using your plugin)
I get nothing on the page and no errors Any help on how to use this within a Group field type would be appreciated.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Using table within Group field type’ is closed to new replies.