Support

Account

Home Forums Add-ons Repeater Field Basic table display of repeater fields

Solving

Basic table display of repeater fields

  • Hi good people — simple request from a wannabe-amateur-minimal-skill newbie to coding.
    I’m building a wordpress site (elegant themes – Divi theme) for music reviews (vinyl), with posts that review albums. In my posts, I’m using an ACF repeater field “tracklist”, with subfields for each song such as track number, track name, rating, notes. The number of songs (and hence repeater field rows) obviously varies for each album/post.

    I simply want to output the results in a nice looking table. Could someone who has repeater field data outputting to a nice looking table please share your code, so I can review your code, learn from it, then plug something that works into my single.php? I’ve been fooling around and can’t get it to output correctly. I’ve reviewed the template code example page for repeaters, but can’t seem to blend that with my basic table code knowledge.

    Thanks for your time!

  • Hello!

    There are a few different ways to do repeaters with field data as tables – I don’t have an example readily available, but if you post the code you’ve been trying to get to work, I can try and point you in the right direction from there.

  • Hi rywn

    I have a similar sort of issue to musiconvinyl above. Hoping you can help me?

    I want to have my data outputted in a sort of table. Like this website:

    http://www.clyde-marine.net/index.php?id=19

    So because I am quite new to custom fields and the repeater plugin I started by watching Elliot Condons video on Vimeo. I copied his code only I used my own names etc. Like this:

    <?php if(get_field(‘vessels’)):?>

    <div class=”vessel”>

    <?php while(has_sub_field(‘vessels’)): ?>

    ” />

    <?php the_sub_field(‘name’); ?>
    <?php the_sub_field(‘type’); ?>
    <?php the_sub_field(‘year’); ?>
    <?php the_sub_field(‘lxb’); ?>
    <?php the_sub_field(‘pull’); ?>
    <?php the_sub_field(‘passengers’); ?>
    <?php the_sub_field(‘spec’); ?>

    <?php endwhile; ?>

    <?php endif; ?>

    </div>

    the outcome at the minute looks like this: http://www.heathermcfadden.co.uk/johnmtest/our-fleet-and-equipment/

    I can’t figure out why the image isn’t showing. When my code to me doesn’t look any different than Elliots. Any ideas?

    I just wanted to get all my fields showing first then I was going to use div’s to lay them out. Not sure if this is the best way to create a table sort of look. So if you think I’m going about it wrong any suggestions would be much appreciated.

    Thanks
    Heather

  • sorry I copied the wrong code, that code above didn’t mention image anywhere…

    
    <?php if(get_field('vessels')):?>
                
                <div class="vessel">
                
    			<?php while(has_sub_field('vessels')): ?>
                
                
                
                <img />" />
                
                <?php the_sub_field('name'); ?>
                <?php the_sub_field('type'); ?>
                <?php the_sub_field('year'); ?>
                <?php the_sub_field('lxb'); ?>
                <?php the_sub_field('pull'); ?>
                <?php the_sub_field('passengers'); ?>
                <?php the_sub_field('spec'); ?>
                
                
                <?php endwhile; ?>
                
    <?php endif; ?>
    
    </div>
    
    i can't get the image line to display its above the sub field called name:
    
    <img src="<code><?php $image = get_sub_field('image'); echo $image['url']; ?></code>" />
    
    only ignore the <code></code> 
    
  • Hi Heather –

    How are you returning your image from ACF? When you create an image field you should get the option for return value – it looks like yours is just returning 1, so you probably have it set to Image Object. Try returning the image URL instead?

    Your code seems to have a stray " /> right after your while, which I think is where your image code is supposed to be, right?

  • Hi

    Yes " /> is where my image code is supposed to be, I couldn’t get it to show up.

    I have my image set to image id the way that elliot has it in this video:

    http://vimeo.com/63015434

    I tried changing it to image url but it made no difference.

    i really don’t know where I have gone wrong…

  • heres what that line of code looks like if it helps.

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Basic table display of repeater fields’ is closed to new replies.