Support

Account

Home Forums Add-ons Repeater Field Displaying repeater field data

Solved

Displaying repeater field data

  • I just purchased the repeater field add on and I am trying to display the repeater field data, but nothing is showing up. The repeater field name is top_links , the sub fields are: link_image and link_url

    The code I am using is:

    <?php while (the_repeater_field('top_links') ): ?> 
                            <li><a href="<?php the_sub_field( 'link_url'); ?>" target="_blank"><?php echo wp_get_attachment_image( get_sub_field( 'link_image' ), 'full' ) ; ?></a></li>
                        <?php endwhile ?>

    What am I missing?

  • <?php while (the_repeater_field('top_links') ): ?> 
                            <li><a href="<?php the_sub_field( 'link_url'); ?>" target="_blank"><?php echo wp_get_attachment_image( get_sub_field( 'link_image' ), 'full' ) ; ?></a></li>
                        <?php endwhile ?>
  • You should use has_sub_field() instead of the_repeater_field()

  • I have tried using both but I am still not seeing any output

  • If you image’s return value is on “Image Object”, you can grab the full size easily. Look at the code below:

    <?php while(has_sub_field('top_links')): ?>
    	<li>
    		<a href="<?php the_sub_field( 'link_url'); ?>" target="_blank">
    			<img src="<?php $image = get_sub_field('link_image'); echo $image['url'] ?>">
    		</a>
    	</li>
    <?php endwhile ?>
  • please edit your first response and delete the code. i believe it’s causing this thread’s layout to break.

  • Great thanks for the heads up on the image, however I am still not seeing the repeater fields output, the has_sub_field(‘top_links’) is not returning and values, or at least that is what I am think, because the while loop is not doing anything

  • Where are you trying to add this repeater field markup? are you within the WP loop? if so, maybe you need to pass the page_id parameter.

    Thanks for fixing the original post, layout was going crazy

  • Can you post a screenshot of your field group? that way I can help you debug this much faster!

  • I am adding it to my header.php file, the repeater field is part of the options page add on as well. I just cant get any output

  • Ah! you need to pass the ‘options’ parameter! code below should work.

    <?php while(has_sub_field('top_links' , 'options')): ?>
    	<li>
    		<a href="<?php the_sub_field( 'link_url'); ?>" target="_blank">
    			<img src="<?php $image = get_sub_field('link_image'); echo $image['url'] ?>" alt="<?php the_sub_field('link_name') ?>">
    		</a>
    	</li>
    <?php endwhile ?>

    edit: updated the code to add the alt tag (using the link_name sub field)

  • adding the options parameter made it work, thank you so much for your help and patience

  • @steve@coplancreativeconsulting.com

    No problem, glad i can help!

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

The topic ‘Displaying repeater field data’ is closed to new replies.