Support

Account

Home Forums Add-ons Flexible Content Field Count taxonomy rows in flexible content Reply To: Count taxonomy rows in flexible content

  • 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; ?>