File: /var/www/html/wp-content/themes/ganryujima_new_1602/single/fighter.php
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<?php
$img = get_field('fighter_img1');
$imgurl = wp_get_attachment_image_src($img, 'full');
$img2 = get_field('fighter_img2');
$img2url = wp_get_attachment_image_src($img2, 'full');
$countryflag = get_field('country_flag');
$countryflagurl = wp_get_attachment_image_src($countryflag, 'full');
?>
<div class="m_title_fighter">
<div class="l-column title">
<h2>
<?php if($countryflagurl){ ?>
<img class="flag" src="<?php echo $countryflagurl[0]; ?>" alt="">
<?php } ?>
<?php the_field('en_name',$post->ID); ?>
</h2>
<h1><?php the_title(); ?></h1>
<?php include(TEMPLATEPATH.'/_page_sns.php'); ?>
</div>
</div>
<section class="l-column m_single_fighter">
<div class="table profile_table">
<div class="cell profile">
<p class="cat">
<?php $terms = get_field('weight_class'); if( $terms ): ?>
<span class="fighter-weight badge"><?php echo $terms[0]->name; ?></span>
<?php endif; ?>
<?php $fields = get_field('base_field'); if( $fields ): ?>
<span class="fighter-base badge"><?php echo $fields[0]->name; ?></span>
<?php endif; ?>
<?php if(get_field('twitter',$post->ID)) { ?>
<i class="fa fa-twitter"></i>
<a href="//twitter.com/<?php the_field('twitter',$post->ID); ?>" target="_blank">
@<?php the_field('twitter',$post->ID); ?>
</a>
<?php } ?>
</p>
<table>
<?php if(get_field('gim',$post->ID)) { ?>
<tr>
<th>所属ジム</th>
<td><?php the_field('gim',$post->ID); ?></td>
</tr>
<?php } ?>
<?php if(get_field('fighter_from',$post->ID)) { ?>
<tr>
<th>国籍</th>
<td><?php the_field('fighter_from',$post->ID); ?></td>
</tr>
<?php } ?>
<?php if(get_field('birthday',$post->ID)) { ?>
<tr>
<th>誕生日</th>
<td><?php the_field('birthday',$post->ID); ?></td>
</tr>
<?php } ?>
<?php if(get_field('hight',$post->ID)) { ?>
<tr>
<th>身長</th>
<td><?php the_field('hight',$post->ID); ?>cm</td>
</tr>
<?php } ?>
<?php if(get_field('weight',$post->ID)) { ?>
<tr>
<th>体重</th>
<td><?php the_field('weight',$post->ID); ?>kg</td>
</tr>
<?php } ?>
</table>
<?php if( have_rows('fight_title') && get_field('show_title')): ?>
<table>
<caption>主なタイトル</caption>
<?php while( have_rows('fight_title') ): the_row(); ?>
<tr class="fight-title">
<th>
<?php the_sub_field('title_year',$post->ID); ?>年
</th>
<td>
<?php the_sub_field('title_name',$post->ID); ?>
</td>
</tr>
<?php endwhile; ?>
</table>
<?php endif; ?>
</div>
<?php if($imgurl){ ?>
<div class="cell image">
<div class="img">
<img class="image" src="<?php echo $imgurl[0]; ?>" alt="">
</div>
</div>
<?php } ?>
</div>
<div class="tables">
<?php if( have_rows('gnryu_title')): ?>
<p class="caption ganryu-fight-title">
巌流島戦績
<span class="en">/<?php if(!wp_is_mobile() || is_Kindle() || is_ipad()){ ?>GANRYUJIMA<?php } ?> FIGHTS</span>
</p>
<table class="ganryu-fight-title">
<tr class="th">
<th style="width: 64px;">勝敗</th>
<th>対戦相手</th>
<?php if(!wp_is_mobile() || is_Kindle() || is_ipad()){ ?>
<th>試合結果</th>
<?php } ?>
<th>試合名</th>
<?php if(!wp_is_mobile() || is_Kindle() || is_ipad()){ ?>
<th style="width: 128px;">開催日時</th>
<?php } ?>
</tr>
<?php while( have_rows('gnryu_title') ): the_row(); ?>
<?php
$fight_result = get_sub_field('fight_result',$post->ID);
$fight_name = get_sub_field('fight_name',$post->ID);
?>
<tr class="<?php if ($fight_result == 'yes') {echo 'won';} ?>">
<td style="width: 64px;">
<?php
if ($fight_result == 'yes') {
echo '<i class="fa fa-circle-o"></i>';
} else {
echo '<i class="fa fa-close"></i>';
}
?>
</td>
<td class="enemy-name">
<?php
$post_object = get_sub_field('enemy');
if( $post_object ):
$post = $post_object;
setup_postdata( $post );
?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
</td>
<?php if(!wp_is_mobile() || is_Kindle() || is_ipad()){ ?>
<td>
<?php the_sub_field('how_win',$post->ID); ?>
</td>
<?php } ?>
<?php
$post_object = get_sub_field('match_name');
if( $post_object ):
$post = $post_object;
setup_postdata( $post );
$date = get_field('event_date',$post->ID);
$year = substr($date, 0, 4);
$month = substr($date, 4, 2);
$days = substr($date, 6, 2);
$day = substr($date, 8);
?>
<td>
<a href="<?php the_permalink(); ?>"><?php the_title(); echo ' "'.$fight_name.'"'; ?></a>
</td>
<?php if(!wp_is_mobile() || is_Kindle() || is_ipad()){ ?>
<td style="width: 128px;">
<?php echo $year.'/'.$month.'/'.$days; ?>
</td>
<?php } ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
</tr>
<?php endwhile; ?>
</table>
<?php endif; ?>
</div>
<div class="table profile_table last">
<div class="cell last-img">
<?php if($img2url){ ?>
<div class="img">
<img class="image" src="<?php echo $img2url[0]; ?>" alt="">
</div>
<?php } ?>
</div>
<div class="cell content">
<div class="l-paper">
<?php the_content(); ?>
</div>
</div>
</div>
<?php include('_links.php'); ?>
</section>
<?php endwhile; endif; ?>