ACFのrepeart-fieldのaddon使って画像を表示するコードの書き方
<?php if(get_field('sub_photorepeat')): ?>
<?php while(the_repeater_field('sub_photorepeat')): ?>
<a href="<?php echo wp_get_attachment_url( get_sub_field( 'sub_photorepeatin',$post->ID) ); ?>">
<?php
$thumbnail_id = get_post_thumbnail_id($post->ID); //アタッチメントIDの取得
$image = wp_get_attachment_image_src( get_sub_field('sub_photorepeatin'), 'singleshinchikusubphoto-thumbnails' ); //「full」サイズのアイキャッチの情報を取得
//url $image[0] 、 横幅 $image[1] 、 高さ $image[2]
echo '<img src="'.$image[0].'" width="'.$image[1].'" height="'.$image[2].'" />';
?>
</a>
<?php endwhile; ?>
<?php endif; ?>
関連記事はこちら!
スポンサーリンク
タグ:ACF, reperter field, 繰り返しフィールド






