Support

Account

Home Forums Add-ons Repeater Field Use repeater field for percentage based A/B testing Reply To: Use repeater field for percentage based A/B testing

  • No problem.

    Below is the code I am using to grab a random selection from a repeater field (‘after_options’).

    <?php 
    	$options = get_field( 'after_options', 'option' );
    	if( is_array( $options ) ) {
    		$option = array_rand( $options ); 
    		$signupHTML = $options[$option]['html'];
    	} 
    ?>
    <div class="signupAfter">
    	<div class="signupText">
    		<?php echo $signupHTML; ?>
    	</div>
    	<div class="signupForm">
    		<input type="text" name="fname" class="fname" placeholder="First">
    		<input type="text" name="lname" class="lname" placeholder="Last">
    		<input type="text" name="email" class="email" placeholder="Email">		 
                    <span class="button">Subscribe</span>
    	</div>
    </div>