Support

Account

Home Forums ACF PRO How do repeater and relationships work together Reply To: How do repeater and relationships work together

  • Thanks. I have tested all the examples on the page and also a relationship that I have on another page without repeaters. But I get no work. This is how my last attempt looks.

    
    <?php if( have_rows('resultat_2015_r1') ): ?>
    
    	<ul class="slides">
        
    	<?php while( have_rows('resultat_2015_r1') ): the_row(); 
    
    		// vars
    		$image = get_sub_field('image');
    		$content = get_sub_field('content');
    		$link = get_sub_field('link');
    	
    		
    		
    		the_sub_field('resultat_r1_placering');
    		
    		
    		the_sub_field('resultat_r1_poang');
    		
    	
    
    						/*
    						*  Query posts for a relationship value.
    						*  This method uses the meta_query LIKE to match the string "123" to the database value a:1:{i:0;s:3:"123";} (serialized array)
    						*/
    
    						$forare = get_posts(array(
    							'post_type' => 'forare',
    							'meta_query' => array(
    								array(
    									'key' => 'tavlingsforare_post', // name of custom field
    									'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
    									'compare' => 'LIKE'
    								)
    							)
    						));
    
    						?>
    						<?php if( $forare ): ?>
    							<ul>
    							<?php foreach( $forare as $forare ): ?>
    								
    								<li>
    									<a href="<?php echo get_permalink( $forare->ID ); ?>">
    										
    										<?php echo get_the_title( $forare->ID ); ?>
    									</a>
    								</li>
    							<?php endforeach; ?>
    							</ul>
    						<?php endif; 
    
    		?>
    
            
            
    		<li class="slide">
            
            
    
    			<?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 echo $content; ?> innehÄll - tavlingsforare_post
                
            
                
    
    		</li>
    
    	<?php endwhile; ?>
    
    	</ul>
    
    <?php endif; ?>