Support

Account

Home Forums General Issues Randomize array content in PHP via WordPress posts Reply To: Randomize array content in PHP via WordPress posts

  • Something like this should get you looking in the right direction.

    <?php if ( have_posts() ) : while ( $fullbanner->have_posts() ) : $fullbanner->the_post(); ?>
    	<?php $banners = get_field(‘home_banner_01_selection’); ?>
    	<?php if( $banners ): ?>
    	
    		<?php shuffle($banners); ?>
    		<?php foreach(array_slice($banners, 0, 1) as $banner ): ?>
    			<?php the_field( 'home_headline', $banner->ID ); ?>
    		<?php endforeach; ?>	
    			
    	<?php endif; ?>
    <?php endif; ?>