2016-10-15 4 views
0

나는 갤러리 필드 부가 기능을 Wordpress 'ACF plugin에 사용하려고합니다. 부가 기능은 Navz Photo Gallery입니다. 갤러리 사진의 ID를 가져 오는 방법을 제공하는 것뿐입니다. 이제 실제로 이미지를 표시하고 싶습니다. 다음 코드자신의 ID를 알고있는 이미지를 표시합니다.

<?php if (get_field('field_name')) { ?> 
    <img src="<?php the_field('field_name'); ?>" /> 
<?php } ?> 

를 호출하여

모든 I는 다음과 같이, 실제 ID가이 얻을 :

<img src="21,22,23"> 

아무도 이미지의이 그룹을 통해 어떻게 루프를 알고 개별적으로 표시됩니까, 신분증뿐 아니라 실제 이미지? 참고로

는 ACF는 공식이있다 (유료) 갤러리에-추가하고이 같은 첨부 된 이미지를 표시합니다

Navz이 나를 도왔다
<?php $images = get_field('gallery'); if($images): ?> 
<?php foreach($images as $image): ?> 
    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> 
<?php endforeach; ?> 
<?php endif; ?> 

답변

0

:

<?php 
$images = get_field('fotos_do_projeto'); if($images): $images = explode(',', $images); $images = array_filter($images); if(count($images)): 
?> 
    <ul> 
    <?php foreach($images as $image): $alt = get_the_title($image); $url = get_post_meta($image, 'field_5802bd6e39e9b_url', true); ?> 
     <li> 
      <a href="<?php echo $url; ?>" title="<?php echo $alt; ?>"> 
       <?php echo wp_get_attachment_image($image, "thumbnail", false, ['alt' => $alt]); ?> 
      </a> 
     </li> 
    <?php endforeach; endif; ?> 
    </ul> 
<?php endif; ?> 
0

당신을 시도해 볼 수 있습니다.

$attachment_id = get_field('field_name'); 
    $image_attributes = wp_get_attachment_image_src($attachment_id); 
    if ($image_attributes) : ?> 
     <img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>" /> 
    <?php endif; ?> 
+0

시간을 내 주셔서 감사합니다. –

관련 문제