Support

Account

Home Forums General Issues how to display (ACF) data/values as a table?

Solving

how to display (ACF) data/values as a table?

  • Good day!

    I did not find anything similar in the forum, so I must to ask for a help 🙂

    We have a gallery with paintings. Every painting is a post.
    Each picture/post has 8 custom fields like:

    firstname
    surname
    year
    title
    etc

    Now we want to create a table for all of the paintings. This table should contain the data/values from custom Filds.

    Is there a way to do this and output data as a table?

    Thanks in advance for your answers!

    Best regards
    Andrej

  • Hi Andrej, I was looking for the same solution, I want to know did you find any solution to create table with acf fields data/ value,
    Please share the information, it will help me alot

  • 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>
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.