Home › Forums › General Issues › how to display (ACF) data/values as a table? › Reply To: how to display (ACF) data/values as a table?
Hi @ajaykasam1
You can just output the values in a table format:
<?php
$firstname = get_field('firstname');
$surname = get_field('surname');
$year = get_field('year');
$title = get_field('title');
?>
<table class="table">
<thed>
<tr>
<?php if( $firstname ): ?>
<th scope="col">First Name</th>
<?php endif; ?>
<?php if( $surname ): ?>
<th scope="col">Surame</th>
<?php endif; ?>
<?php if( $year ): ?>
<th scope="col">Year</th>
<?php endif; ?>
<?php if( $title ): ?>
<th scope="col">Title</th>
<?php endif; ?>
</tr>
</thed>
<tbody>
<tr>
<?php if( $firstname ): ?>
<th scope="row">First Name</th>
<?php endif; ?>
<?php if( $surname ): ?>
<td>Surame</td>
<?php endif; ?>
<?php if( $year ): ?>
<td>Year</td>
<?php endif; ?>
<?php if( $title ): ?>
<td>Title</td>
<?php endif; ?>
</tr>
</tbody>
</table>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.