Support

Account

Forum Replies Created

  • Okay, I made some progress! 🙂

    I realized that the reason the code loop didnt keep running is because I needed to keep calling in a new query for the other pieces. My new code is:

    <b> Featured Games </b>
    
    <?php 
    $args = array (
    	'post_type'      	=> 'featured_games',
    	'posts_per_page'	=> 15,
    	'post_status'		=> 'publish',
    	'orderby'        	=> 'date',
    );
    $the_query = new WP_Query($args);
    if ( $the_query->have_posts() ) : ?> 	
    	<div class="row">
    		 
    			<div class="col-md-5">
    				<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> 
    						<?php	$home = get_field('home_team');
    						if( $home ): ?>
    						<?php		foreach( $home as $post):
    										setup_postdata($post);
    										the_post_thumbnail();   
    									endforeach;
    									wp_reset_postdata(); ?>
    							
    						<?php endif; ?>	
    				<?php  endwhile; ?>
    			</div>
    
    			<div class="col-md-2">
    				<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> 				
    						<?php the_field('vs_or_at'); ?> 		
    				<?php  endwhile; ?>
    			</div>
    	 	 
    			<div class="col-md-5">
    				<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> 
    						<?php $visiting = get_field('visiting_team');
    						if( $visiting ): ?>
    								<?php 	foreach( $visiting as $post): 
    										setup_postdata($post);     
    										the_post_thumbnail();
    										endforeach; 
    									wp_reset_postdata(); ?>	
    						<?php endif; ?>
    				<?php  endwhile; ?>
    			</div>
    		  
    	</div>
    <?php endif; ?>	

    Now my problem is instead of looping through and showing one of each, then repeating, I’m getting all of one, then all of the next, then all of the third.

    So ideally I’d like to see:
    Home Team vs/at Visiting Team
    Home Team vs/at Visiting Team
    Etc..

    But right now I’m seeing
    Home Team Home Team … vs/at vs/at … Visiting Team Visiting Team

    I’m sure it’s a loop thing… but I can’t quite put my finger on it… I know it’s going to be real obvious once I (or someone else) finds it. haha

    Thanks again in advance!

Viewing 1 post (of 1 total)