Home Forums ACF PRO ACF Repeater returns Sub-row count instead of array


ACF Repeater returns Sub-row count instead of array

  • Hi there,

    I have a widget that display several fields from a specific post (within a Custom Post Type).

    The problem is that if I loop through a Repeater fields, then it returns an INT which represents the count of the rows, but not the rows itself.

    Tried event with get_post or query_posts: the first one didn’t work, query_posts breaks the layout (maybe because i’m using Site Origin Page Builder to build pages).

    // $carousel_id comes from the widget's UI and it's a post ID
    $args = array(
    				'post_type' => 'carosello_custom',
    				'post__in' => array($carousel_id),
    			$carousel_query = new WP_Query($args);
    	        echo "<div class='latest-post-carousel'>";
    	        if($title) {
    	        	echo "<h2 class='carousel-heading'>".$title."</h2>";
    	        echo "<div class='generic-carousel custom-carousel'>";
    	        while ( $carousel_query->have_posts() ) {
    	        	if( have_rows('elementi') ):
    	        		// loop through the rows of data
    				    while ( have_rows('elementi') ) : the_row(); ?>
    				    <div class="carousel-item">
            				<a class="permalink" href="<?php the_sub_field('link_el'); ?>" title="<?php the_sub_field('titolo_el'); ?>">
            					$cover = get_sub_field('immagine_el');
    							$the_title_attr = get_sub_field('titolo_el');;
    							if($cover) {
    								$thumb = $cover['sizes']['thumbnail'];
    								echo "<img src='$thumb' alt='$the_title_attr'>";
    	        			<h3 class="entry-title"><?php the_sub_field('titolo_el'); ?></h3>
    	        			<span class="carousel-button">SCOPRI</span>
    				else :
    					// tried some debug here
    					the_field('elementi'); // Repeater field: returns row count
    					the_field('test_r'); // Repeater field: returns row count
    					the_field('testo'); // Text field: returns content
    	        echo '</div><!-- .posts-carousel -->';
    	        echo '</div><!-- .latest-post-carousel -->';
Viewing 1 post (of 1 total)

The topic ‘ACF Repeater returns Sub-row count instead of array’ is closed to new replies.