アドバンスカスタムフィールド 関連

参考http://kotori-blog.com/wordpress/acf_output/

//関連(返り値は「Post Objects」)
$kanren = get_field('kanren');
if($kanren){ ?>
<p>関連:<? foreach((array)$kanren as $value) {
    echo '<a href="'.get_the_permalink($value->ID).'">'.$value->post_title.'</a>';
    if ($value !== end($kanren)) {
        echo ", ";
    }
} ?></p><? }

2015.06.20追記

しっかりまとめ

<?php
//関連(返り値は「Post Objects」)
$kanren = get_field('kanren_tour');
if($kanren){ ?>


<h3 class="kanren_tour">
関連のあるツアー
</h3>
<?php foreach((array)$kanren as $value) {
   
   // if ($value !== end($kanren)) {
    //    echo ", ";
   // }
   ?>
    
<?php include("a1_d_tour_roop_main_ichiran2_ac.php"); ?>
    
<?php } ?>
<? } ?>

a1_d_tour_roop_main_ichiran2_ac.php

<!--box--><div class="top_box1">

<!--img-->
<a href="<?php echo get_the_permalink($value->ID) ?>" class="block">
<div class="top_box1_img_box">
 <?php //画像ファイルにクラスをつけて表示 mediumを任意のサイズへ 最後array(120,240)など
$title= $value->post_title;
$img_url2  = wp_get_attachment_image_src(get_post_meta($value->ID,"main_img",true),'tour-sam1'); ?>
<img src="<?php print $img_url2[0];  ?>" class="top_sam1" alt="<?php echo $title ?>" title="<?php echo $title ?>" />

<?php  //厳選ツアーなら
if (is_object_in_term($value->ID, 'bali-tours-cat','おすすめ厳選ツアー')): ?>
<div class="top_box1_icon">
<img src="/img/d_this/osusume.png"  alt="厳選おすすめバリ島ツアー" class="no_dhover"></div>

<?php endif; //厳選ツアーならEND ?>


<div class="top_box1_coco">
<img src="/img/d_this/coconatu.png" width="95" height="105" alt="バリ島イメージ・ヤシの木"class="no_dhover">
</div>

</div>
</a>
<!--img-->

<!--disp-->
<div class="top_disp1">
<h3 class="top_disp1_title"><?php //ランキング分岐1
 
  include("a2_d_rank1_ac.php"); ?> 
<a href="<?php echo get_the_permalink($value->ID) ?>">
<?php echo $title ?>
</a>
</h3>
<p class="top_disp1_p">
<a href="<?php echo get_the_permalink($value->ID) ?>">
<?php echo get_post_meta($value->ID,"tour_disp",true); ?>
</a>

<br><br>
<a href="<?php echo get_the_permalink($value->ID) ?>" class="tuzuki">詳しく見る▶</a>
</p>

</div>

<!--/disp-->
<div style="clear:both;"></div>

</div><!--/box--> 

a2_d_rank1_ac.php

<?php  //ランキング写真内
if (is_object_in_term($value->ID, 'bali-tours-ranking','1位')): ?>
<img src="/img/d_this/rank/big_crawn1.png"  class="rank1d" alt="バリツアー人気No1" />
<?php elseif (is_object_in_term($value->ID, 'bali-tours-ranking','2位')): ?>
<img src="/img/d_this/rank/big_crawn2.png"  class="rank1d" alt="バリツアー人気No2" />
<?php elseif (is_object_in_term($value->ID, 'bali-tours-ranking','3位')): ?>
<img src="/img/d_this/rank/big_crawn3.png"  class="rank1d" alt="バリツアー人気No3" />
<?php elseif (is_object_in_term($value->ID, 'bali-tours-ranking','4位')): ?>
<img src="/img/d_this/rank/big_crawn4.png"  class="rank1d" alt="バリツアー人気No4" />
<?php elseif (is_object_in_term($value->ID, 'bali-tours-ranking','5位')): ?>
<img src="/img/d_this/rank/big_crawn5.png"  class="rank1d" alt="バリツアー人気No5" />
<?php elseif (is_object_in_term($value->ID, 'bali-tours-ranking','6位')): ?>
<img src="/img/d_this/rank/big_crawn6.png"  class="rank1d" alt="バリツアー人気No6" />
<?php elseif (is_object_in_term($value->ID, 'bali-tours-ranking','7位')): ?>
<img src="/img/d_this/rank/big_crawn7.png"  class="rank1d" alt="バリツアー人気No7" />
<?php elseif (is_object_in_term($value->ID, 'bali-tours-ranking','8位')): ?>
<img src="/img/d_this/rank/big_crawn8.png"  class="rank1d" alt="バリツアー人気No8" />
<?php elseif (is_object_in_term($value->ID, 'bali-tours-ranking','9位')): ?>
<img src="/img/d_this/rank/big_crawn9.png"  class="rank1d" alt="バリツアー人気No9" />
<?php elseif (is_object_in_term($value->ID, 'bali-tours-ranking','10位')): ?>
<img src="/img/d_this/rank/big_crawn10.png"  class="rank1d" alt="バリツアー人気No10" />
<?php elseif (is_object_in_term($value->ID, 'bali-tours-ranking','11位')): ?>
<img src="/img/d_this/rank/big_crawn11.png"  class="rank1d" alt="バリツアー人気No11" />
<?php elseif (is_object_in_term($value->ID, 'bali-tours-ranking','12位')): ?>
<img src="/img/d_this/rank/big_crawn12.png"  class="rank1d" alt="バリツアー人気No12" />
<?php else: ?> 
  <?php endif; ?>