<?php
// check if the repeater field has rows of data
if( have_rows('任意のフィールド名') ):
// loop through the rows of data
while ( have_rows('任意のフィールド名') ) : the_row();
// display a sub field value
the_sub_field('任意のカスタムフィールド名');
endwhile;
else :
// no rows found
endif;
?>
画像を読むこむときは少し特殊でfunctions.phpに下記を書き込む
function ACF_img($str,$size_name='full',$type='photo',$row=''){
//空入力を有効に
if($type ==''){$type = 'photo';}
//rowを第2因数以降でも有効に
if($size_name == 'row' || $type == 'row' ){
$row = 'row';
$type='photo';
$size_name='full';
}
//rowの処理
if($row != 'row'){
$image = get_field($str);
}else{
//繰り返し(repeater)の画像呼び出し
$image = get_sub_field($str);
}
//画像情報の読み込み
if( !empty($image) ){
// vars
$url = $image['url'];
$alt = $image['alt'];
$title = $image['title'];
$caption = $image['caption'];
// Resize
if(($size_name != '') && ($size_name != 'full')){
$thumb = $image['sizes'][$size_name];
}else{
$thumb = $url;
}
switch ($type){
case 'photo': $photo = '<img src="'.$thumb.'" alt="'.$alt.'" />';break;
case 'url': $photo = $thumb;break;
case 'alt': $photo = $image['alt'];break;
case 'title': $photo = $image['title'];break;
case 'caption': $photo = $image['caption'];break;
}
echo $photo;
}
}
テンプレートには下記を入れ込む。
<?php ACF_img('img_01','','','row'); ?>
参考サイト