Support

Account

Home Forums ACF PRO while have rows for acf blocks?

Unread

while have rows for acf blocks?

  • Hello,

    I started yesterday to build a template with acf_register_block_type.
    Before I always used flexible fields for my customers website.
    To load the scripts for each flexible content just if they are needed (and to implement a php counter to the scripts i used a code like e.g.:

    <script>	
    <?php
    $scriptCounter = 0;
    if( have_rows('flexible_field') ):
        while ( have_rows('flexible_field') ) : the_row();
    
            if( get_row_layout() == 'counter' ): 
    	       if ($scriptCounter == 0): ?>
    
    		    /* Here goes some js */
    
    		 <?php 
                     $scriptCounter++; 
    	       endif;
    	endif;
        endwhile;
    endif;?>
    </script>

    Is there something similar to the acf blocks so I can use a php statement to do something each time a block is used on a page? I would be really happy if someone could help me with this.

    Thanks a lot.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.