Lowell Klassen Posted March 25, 2020 Share Posted March 25, 2020 Hi Guys, I'm looking to convert the following an ACF Table that outputs <tr>. <td>, etc. tags, into div tags, so that it's responsive in my WordPress website. Can anyone help me? <!--CODE STARTS--> <?php $table = get_field( 'table1' ); if ( $table ) { echo "<div style=\"text-align:center\">"; echo '<table>'; if ( $table['header'] ) { echo '<thead><tr>'; echo ''; 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>'.$td['c'].'</td>'; } echo '</tr>'; } echo '</tbody>'; echo '</table>'; } ?> <?php the_field( '' ); ?> <!--CODE ENDS--> If you could help me out, I would greatly appreciate it. Thanks! This is where it is now at the bottom of the page. I would like to center it too: https://www.schnellindustries.ca/lowell/conveyors/ - Lowell Link to comment Share on other sites More sharing options...
0 Dick Montage Posted November 24, 2020 Share Posted November 24, 2020 Are you referring to the MODELS table? Apologies: This just popped up in the feed for some reason, even though posted back in March! Link to comment Share on other sites More sharing options...
Question
Lowell Klassen
Hi Guys,
I'm looking to convert the following an ACF Table that outputs <tr>. <td>, etc. tags, into div tags, so that it's responsive in my WordPress website.
Can anyone help me?
<!--CODE STARTS-->
<?php $table = get_field( 'table1' );
if ( $table ) {
echo "<div style=\"text-align:center\">";
echo '<table>';
if ( $table['header'] ) {
echo '<thead><tr>';
echo '';
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>'.$td['c'].'</td>';
}
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
} ?>
<?php the_field( '' ); ?>
<!--CODE ENDS-->
If you could help me out, I would greatly appreciate it. Thanks!
This is where it is now at the bottom of the page. I would like to center it too: https://www.schnellindustries.ca/lowell/conveyors/
- Lowell
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now