Support » Plugin: Advanced Custom Fields » repeater field working on one page but not others

  • Resolved bshuchter

    (@bshuchter)


    Strange problem I’m having. I have one template with a repeater field on it, and several pages which use that one template. But only one of the pages shows the content of the repeater field – the others are blank. Even if I try to “force” the repeater field to see the content of one of the other pages, it’s still blank. The code I’m using in the template is very simple:

    if (get_field('photos')) {
    	echo '<div id="photo-gallery">';
    	while (has_sub_field('photo'))
    	{
    		echo '<img class="alignleft size-thumbnail" src="';
    		echo get_sub_field('photo');
    		echo '" />';
    	}
    	echo '</div>';
    }

    On one of the pages, this code displays all the photos uploaded to the repeater field, as expected. On every other page using the same template, it displays nothing (but does echo the div tag).

    I upgraded ACF to 3.5.4 in the middle of developing this site, so not sure if that caused the problem.

    http://wordpress.org/extend/plugins/advanced-custom-fields/

Viewing 1 replies (of 1 total)
  • I managed to fix this problem by using a different loop, namely:

    $rows = get_field('photos');
    if ($rows) {
    	echo '<div id="photo-gallery">';
    	foreach ($rows as $row) {
    		echo '<img class="alignleft size-thumbnail" src="';
    		echo $row['photo'];
    		echo '" />';
    	}
    	echo '</div>';
    }

    It now shows up properly in every page using that template.

Viewing 1 replies (of 1 total)
  • The topic ‘repeater field working on one page but not others’ is closed to new replies.