カスタム投稿タイプにのカスタムタクソノミーでリピーターフィールドの出力
まずはACFのThe Repeater Field(繰り返しフィールド)のループのサンプルコード
サンプルコード:Advanced Loop
<?php if( have_rows('repeater_field_name') ): ?>
<ul class="slides">
<?php while( have_rows('repeater_field_name') ): the_row();
// vars
$image = get_sub_field('image');
$content = get_sub_field('content');
$link = get_sub_field('link');
?>
<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; ?>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
上記のコードをもとに表示してるタームのIDを取得して、リピーターフィールドにIDを指定したのが下のコードをtaxonomy.php( taxonomy-タクソノミー名.php )に記述する
<?php
$term_id = get_queried_object()->term_id;
$term_idsp = 'タクソノミー名_'.$term_id;
?>
<?php if( have_rows('リピーターフィールド名',$term_idsp) ): ?>
<ul class="slides">
<?php while( have_rows('リピーターフィールド名',$term_idsp) ): the_row();
// vars
$image = get_sub_field('image');
$content = get_sub_field('content');
$link = get_sub_field('link');
?>
<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; ?>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>