Home › Forums › Add-ons › Repeater Field › Rotating Clickable Banner Code › Reply To: Rotating Clickable Banner Code
Thanks for your response. I got some help, and here is the final code that we went with below. I’m not sure what the ’76’ does, but hope this helps others in the future.
<?php if( have_rows('title', 76) ): ?> <?php // Get the repeater field $repeater = get_field( 'title', 76 ); // Get a random row. $random_row = array_rand( $repeater, 1 ); // Get subfields $image = $repeater[$random_row]['image']; $link = $repeater[$random_row]['link']; ?> <?php if( $link ): ?> <a href="<?php echo $link; ?>"> <?php endif; ?> <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" /> <?php if( $link ): ?> </a> <?php endif; ?> <?php endif; ?>
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!
Accordions are a great way to group related information while allowing users to interactively show and hide content. In this video, Damon Cook goes in-depth on how to create an accessible accordion block using ACF PRO’s Repeater field.https://t.co/RXT0g25akN— Advanced Custom Fields (@wp_acf) March 2, 2023
© 2023 Advanced Custom Fields.