File: /var/www/html/wp-content/themes/ganryujima_new_1602/single/events.php
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<?php
$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);
?>
<div class="event_title table">
<div class="date">
<span>
<span class="year"><?php echo $year ; ?></span>
<span class="days"><?php echo $month.'.'.$days ; ?></span>
<span class="day">(<?php echo $day ; ?>)</span>
</span>
</div>
<div class="cell">
<h1>
<?php the_title(); ?>
<aside><i class="fa fa-clock-o"></i><?php the_field('time',$post->ID); ?></aside>
</h1>
<?php include(TEMPLATEPATH.'/_page_sns.php'); ?>
</div>
</div>
<?php if(get_the_content()) : ?>
<div class="l-paper event_content">
<?php the_content(); ?>
</div>
<?php endif; ?>
<?php $rows = get_field('card_table'); if( $rows ): ?>
<div class="l-paper event_content">
<?php include('_fight_card.php'); ?>
</div>
<?php endif; ?>
<div class="event_cover">
<?php
$img = get_field('cover');
$imgurl = wp_get_attachment_image_src($img, 'full');
$author = get_field('author',$post->ID);
$sponsor = get_field('sponsor',$post->ID);
$format = get_field('format',$post->ID);
$rule = get_field('rule',$post->ID);
$period = get_field('period',$post->ID);
$ticket_info_center = get_field('ticket_info_center',$post->ID);
?>
<?php if($imgurl){ ?><img class="cover" src="<?php echo $imgurl[0]; ?>" alt=""><?php } ?>
</div>
<table class="m-table m-event-table">
<tr>
<th>大会名</th>
<td><?php the_title(); ?></td>
</tr>
<tr>
<th>日時</th>
<td>
<p><?php echo $year.'年'.$month.'月'.$days.'日'.$day ; ?></p>
<p><?php the_field('time',$post->ID); ?></p>
</td>
</tr>
<tr>
<th>会場</th>
<td>
<p><strong><?php the_field('place',$post->ID); ?></strong></p>
<p><?php the_field('address',$post->ID); ?></p>
<p>
<a href="<?php the_field('url',$post->ID); ?>" target="_blank">
<?php the_field('url',$post->ID); ?>
</a>
</p>
<p><?php the_field('access',$post->ID); ?></p>
</td>
</tr>
<?php if($author) { ?>
<tr>
<th>主催</th>
<td><?php echo $author; ?></td>
</tr>
<?php } ?>
<?php if($sponsor) { ?>
<tr>
<th>協賛</th>
<td><?php echo $sponsor; ?></td>
</tr>
<?php } ?>
<?php
$fighter = get_field('fighter');
$other_fighter = get_field('other_fighter');
if( $fighter || $other_fighter.length > 0) {
?>
<tr>
<th>出場選手</th>
<td>
<? if($fighter){
foreach((array)$fighter as $value) {
echo '<a href="'.get_the_permalink($value->ID).'">'.$value->post_title.'</a>';
if ($value !== end($fighter)) {
echo "/";
}
}
} ?>
<?php if( have_rows('other_fighter') ): ?>
<?php while( have_rows('other_fighter') ): the_row(); ?>
<?php
$fighter = get_field('fighter'); if($fighter){
echo "/";
}
the_sub_field('fighter_name',$post->ID);
?>
<?php endwhile; ?>
<?php endif; ?>
</td>
</tr>
<?php } ?>
<?php if($format) { ?>
<tr>
<th>試合形式</th>
<td><?php echo $format; ?></td>
</tr>
<?php } ?>
<?php if($rule) { ?>
<tr>
<th>ルール</th>
<td><?php echo $rule; ?></td>
</tr>
<?php } ?>
<tr>
<th>入場料金(税込)</th>
<td>
<?php if( have_rows('ticket_price') ): ?>
<table class="m-reset-table">
<?php while( have_rows('ticket_price') ): the_row(); ?>
<tr>
<th><?php the_sub_field('seat',$post->ID); ?></th>
<td><?php the_sub_field('price',$post->ID); ?>円</td>
<td class="red"><?php if ( get_sub_field('soldout')) {echo '完売';} ?></td>
</tr>
<?php endwhile; ?>
</table>
<?php endif; ?>
<?php the_field('tichet_price_info',$post->ID); ?>
</td>
</tr>
<?php if($period) { ?>
<tr>
<th>チケット発売日</th>
<td><?php echo $period; ?></td>
</tr>
<?php } ?>
<tr>
<th>チケット発売所</th>
<td>
<?php if( have_rows('ticket_shop') ): ?>
<ul>
<?php while( have_rows('ticket_shop') ): the_row(); ?>
<li>
<a href="<?php the_sub_field('shop_url',$post->ID); ?>" target="_blank">
<strong><?php the_sub_field('shop_name',$post->ID); ?></strong>
<i class="fa fa-external-link"></i>
</a>
<p>
TEL:
<a href="telto:<?php the_sub_field('shop_tel',$post->ID); ?>">
<?php the_sub_field('shop_tel',$post->ID); ?>
</a>
(<?php the_sub_field('shop_info',$post->ID); ?>)
</p>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
</td>
</tr>
<?php if($ticket_info_center) { ?>
<tr>
<th>チケットに関するお問い合せ</th>
<td><?php echo $ticket_info_center; ?></td>
</tr>
<?php } ?>
<?php
$tv = get_field('tv');
if( $tv.length > 0) {
?>
<tr>
<th>放送</th>
<td>
<?php if( have_rows('tv') ): ?>
<?php while( have_rows('tv') ): the_row(); ?>
<?php the_sub_field('tv_info',$post->ID); ?>
<?php the_sub_field('tv_date',$post->ID); ?>
<?php the_sub_field('tv_time',$post->ID); ?>
<?php endwhile; ?>
<?php endif; ?>
</td>
</tr>
<?php } ?>
</table>
<?php include('_links.php'); ?>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>