Support

Account

Home Forums General Issues show images of relationship custom post

Solved

show images of relationship custom post

  • hi,

    how to show images of custom post client?
    i followed this guide
    http://www.advancedcustomfields.com/resources/relationship/

     <?php 
    		
    
    $posts = get_field('brand_hp');
    
    if( $posts ): ?>
    	
    	<?php foreach( $posts as $client ): // variable must NOT be called $post (IMPORTANT)
    	
    		 $logo_hover = get_field('logo_hover');
                     $logoclient = get_field('logo');
    		
    	 ?>
    	    <div class="brand">
    	    	<a href="<?php echo get_permalink( $client->ID ); ?>">
    			<img class="img-cliente" src="<?php echo $logoclient['url']; ?>" alt="<?php echo $logoclient['alt']; ?>" />
                           <img src="<?php echo $logo_hover['url']; ?>" alt="<?php echo $logo_hover['alt']; ?>" />
    		 </a>
                
                
                
                </div>
    	    	
    	   
    	<?php endforeach; ?>
    	
    <?php endif; ?>
  • Hi @manucnx

    Since you’re not in a real loop you need to specify the second parameter for each function call:

    
    <?php 	
    $posts = get_field('brand_hp');
    if( $posts ): ?>
    	<?php foreach( $posts as $client ): ?>
    		<?php 
    		$logo_hover = get_field('logo_hover', $client->ID);
            $logoclient = get_field('logo', $client->ID);
    		?>
    	    <div class="brand">
    	    	<a href="<?php echo get_permalink( $client->ID ); ?>">
    				<img class="img-cliente" src="<?php echo $logoclient['url']; ?>" alt="<?php echo $logoclient['alt']; ?>" />
                	<img src="<?php echo $logo_hover['url']; ?>" alt="<?php echo $logo_hover['alt']; ?>" />
    			</a>
            </div>
    	<?php endforeach; ?>
    <?php endif; ?>
    
  • No problem.

    Feel free to post in the forum whenever you have issues with ACF and we’ll try to help you.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.