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>
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.