Hi @jonathan, I found the solution.
Im not sure why this would break the count();
.
Do you know why?
This is what I had:
if ( have_rows('repeater') ) :
$counter = get_sub_field('repeater');
// $counter = get_field('repeater'); if not in Flexible Content
while ( have_rows('repeater') ) : the_row();
$count = count( $counter );
echo $count;
// HTML goes here
endwhile;
endif;
And this is what works:
$counter = get_sub_field('repeater');
// $counter = get_field('repeater'); if not in Flexible Content
if ( have_rows('repeater') ) :
while ( have_rows('repeater') ) : the_row();
$count = count( $counter );
echo $count;
// HTML goes here
endwhile;
endif;
Hi @jonathan, this is what I have:
<?php if( have_rows('section') ):
while ( have_rows('section') ) : the_row();
// Repeater Block
if ( get_row_layout() == 'content_block_repeater' ):
// Repeater Field
if( have_rows('repeater') ) :
$counter = get_sub_field('repeater');
//$counter = get_field('repeater');
echo '<div class="repeater_block">';
// Loop
while ( have_rows('repeater') ) : the_row();
$h3 = get_sub_field('repeater_h3');
$em = get_sub_field('repeater_em');
$count = count( $counter );
if ( $count == 3 ) {
$span = 'span33';
} elseif ( $count == 2 ) {
$span = 'span50';
} else {
$span = 'span100';
}
// Output
echo '<div class="'. $span .'">';
echo '<h3>'. $h3 .'</h3>';
echo '<em>'. $em .'</em>';
echo '</div>';
// End Output
endwhile;
// End Loop
echo '</div>';
endif;
// Text Block
elseif ( get_row_layout() == 'content_block_text' ):
// get_template_part( '/_content/text' );
else :
// No Content
endif;
endwhile;
endif; ?>
Hey, I am having this same problem.
I can count repeater rows normally. But if there is a repeater field inside the Flexible Content it won’t count.
I have tired “get_field” and “get_sub_field” using the code by @jonathan but doesn’t count.
Any luck @mantismamita ?
Thanks
I have been using something like this for my projects.
hope it helps.
This code is on the taxonomy-(your taxonomy).php file
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); // get current term ?>
<?php if ( have_rows('category_slideshow', $term) ): ?>
<?php while ( have_rows('category_slideshow', $term) ) : the_row();
$img = get_sub_field('category_slideshow_image', $term);
?>
<img src="<?php echo $img['url']; ?>" alt="<?php echo $img['alt'] ?>" />
<?php endwhile; ?>
<?php endif; ?>
Update!
I have read all the posts about memory limits and database character length.
I have resolved my issue by changing the Taxonomy name from:
“collections-category” to “coll-cat”.
It must of been too long to store in the DB.
Worth knowing for anyone else having this issue.
Cheers
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.