Support

Account

Home Forums ACF PRO Repeater in template parts

Solving

Repeater in template parts

  • Hello!

    I have a relation what loops related items, in every loop I include a template-file: include(locate_template(‘includes/template-parts/template-part-projects-small-item-loop.php’)); this file includes an other file: include(locate_template(‘includes/template-parts/template-part-spot-hover-header-block.php’)); which contain a repeater. I run the code above two times to display large and small spots, the only differance is the first include file. The problem I have is that the repeater values are not found in the second time. If I put two var_dumps on have_rows(‘project-headers’) in the template-part-spot-hover-header-block.php it show false true and then works. What can I do to skip the var_dumps and get it working. I also use setup_postdata($post); and wp_reset_postdata(); when I loop the relations.

  • I´ve solved it, but not using the have_rows function. Instead I get the rows with $rows = get_field(‘project-headers’); and then do a foreach.

  • Same sort of problem here: when using the_row() it steps through the rows and if I happen to have it structured such that it’s the same “loop”, I’ve already used up some rows. I wish there were a function like reset_rows() to ensure that the_row() is going to start at the beginning again.

  • Hi @freke1981 and @themediumutm

    Thank you guys for the posts 🙂

    @themediumutm I agree this function would really be helpful when creating your loops.

    I have passed this feature request to Elliot and hopefully this will see its way into the plugin sometime soon.

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

You must be logged in to reply to this topic.