Support

Account

Home Forums Add-ons Repeater Field Making Repeater work in a theme (Headway)

Solved

Making Repeater work in a theme (Headway)

  • Hi friends,

    I am using the following repeater:

    – video_tutorial
    — title
    — outline
    — embed
    –summary
    — downloads

    And the following code to display each sub field

    <?php
    
    // check if the repeater field has rows of data
    if( have_rows('video_tutorial') ):
    
     	// loop through the rows of data
        while ( have_rows('video_tutorial') ) : the_row();
    
            // display a sub field value
            the_sub_field('title');
    
        endwhile;
    
    else :
    
        // no rows found
    
    endif;
    
    ?>

    The thing is that when I add two elements, my visual framework (Headway) does not create a new “video_tutorial” instance . Instead of displaying something like:

    – video_tutorial 1
    — title 1
    — outline 1
    — embed 1
    –summary 1
    — downloads 1

    – video_tutorial 2
    — title 2
    — outline 2
    — embed 2
    –summary 2
    — downloads 2

    It displays something like:
    – video_tutorial 1
    — title 1
    — title 2
    — outline 1
    — outline 2
    — embed 1
    — embed 2
    –summary 1
    –summary 2
    — downloads 1
    — downloads 2

    My question is: How can I display this correctly in Headway? Is there a special PHP code I need to enter in the custom code besides what I am already using?

    Thanks so much

  • Are you outputting all of the sub fields in the same loop?

    
    <?php
    // check if the repeater field has rows of data
    if( have_rows('video_tutorial') ):
     	// loop through the rows of data
        while ( have_rows('video_tutorial') ) : the_row();
            // display a sub field value
            the_sub_field('title');
            echo '<br>';
            the_sub_field('outline');
            echo '<br>';
            the_sub_field('embed');
            // etc...
    
        endwhile;
    
    else :
    
        // no rows found
    
    endif;
    
    ?>
    
  • I’m not. I’m trying to use one “block” (as Headways call it) per subfield. What do you think?

  • I don’t know anything about blocks in headway, but that’s the reason why you’re getting the output your getting. Basically you’re looping through the repeater and showing all of the values for a single field in all rows, then you’re looping through it again and showing the fields for the rows of the next field.

    What you’re going to have to do is show all the values of each row and incorporate the needed HTML into it.

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

The topic ‘Making Repeater work in a theme (Headway)’ is closed to new replies.