﻿<?php
/*
Template Name: スケジュールカテゴリ一覧用
*/
?>

<?php
$metakey = 'event_date'; //カスタムフィールドで設定した名前
$metatoday = date( "Ymd" ); //設定した日付の書式
$current_date = date_i18n( 'ymd' ); //今日の日付取得

$args = array(
'meta_key' => $metakey,
'meta_value' => $metatoday,
'category_name' => 'seminar',
'meta_compare' => '>',
'meta_query' => array(
	'relation' => 'AND',
	array(
		'key' => 'event_date', //セミナー開催日
		'value' => $current_date,
		'compare' => '>', //セミナー開催日が今日よりあと
		'type' => 'DATE' //日付の比較
	),
),
'orderby' => 'meta_value',
'order' => 'ASC',
'type' => 'DATE',
);
$the_query = new WP_Query( $args );
?>

			<section class="sectionLv01 clearfix">
    	    	<div class="about-box">
	                <h3 class="h3box">セミナー・イベント等の開催予定</h3>
				
					<dl class="dl-archives clearfix">
					
					
						<?php
							if ( $the_query->have_posts() ) : 
								while ( $the_query->have_posts() ) :
									$the_query->the_post();
						?>
							<dt><?php $eventdate = get_post_meta( $post->ID , 'event_date' ,true);
								$nen = substr($eventdate, 0,4);
								$tsuki = substr($eventdate, 4,2);
								$hi = substr($eventdate, 6,2);
								$week = array( "日", "月", "火", "水", "木", "金", "土" );
								echo $nen."年".$tsuki."月".$hi."日"." (".$week[date("w", strtotime($nen."-".$tsuki."-".$hi))].")"; ?></dt>
							<dd>
								<?php if (get_the_title() == "八幡法人会創立50周年記念講演会") { ?><a href="/50th/"><?php the_title();?></a>
								<?php } elseif (get_the_content() != "") { ?><a href="<?php the_permalink(); ?>"><?php the_title();?></a>
								<?php } else { ?><?php the_title();?>
								<?php } ?>
								<?php
									$days=7;
									$today=date('U'); $entry=get_the_time('U');
									$diff1=date('U',($today - $entry))/86400;
									if ($days > $diff1) {
								?>
									<img src="<?php bloginfo('stylesheet_directory'); ?>/img/common/new.gif" width="18" height="8" alt="new">
								
							</dd>
						<?php } ?>
						<?php
								endwhile;
							elseif ( !$the_query->have_posts() ):
								echo("現在１件もありません。");
							endif;
						?>
					</dl>
				</div><!-- /about-box -->
			<!-- /sectionLv01 --></section>
<?php wp_reset_query(); ?>



<?php
$metakey = 'event_date'; //カスタムフィールドで設定した名前
$metatoday = date( "Ymd" ); //設定した日付の書式
$current_date = date_i18n( 'ymd' ); //今日の日付取得

$args = array(
'meta_key' => $metakey,
'meta_value' => $metatoday,
'category_name' => 'meeting',
'meta_compare' => '>',
'meta_query' => array(
	'relation' => 'AND',
	array(
		'key' => 'event_date', //セミナー開催日
		'value' => $current_date,
		'compare' => '>', //セミナー開催日が今日よりあと
		'type' => 'DATE' //日付の比較
	),
),
'orderby' => 'meta_value',
'order' => 'ASC',
'type' => 'DATE',
);
$the_query = new WP_Query( $args );
?>

			<section class="sectionLv01 clearfix">
    	    	<div class="about-box">
	                <h3 class="h3box">会議等の開催予定</h3>
				
					<dl class="dl-archives clearfix">
					
					
						<?php
							if ( $the_query->have_posts() ) : 
								while ( $the_query->have_posts() ) :
									$the_query->the_post();
						?>
							<dt><?php $eventdate = get_post_meta( $post->ID , 'event_date' ,true);
								$nen = substr($eventdate, 0,4);
								$tsuki = substr($eventdate, 4,2);
								$hi = substr($eventdate, 6,2);
								$week = array( "日", "月", "火", "水", "木", "金", "土" );
								echo $nen."年".$tsuki."月".$hi."日"." (".$week[date("w", strtotime($nen."-".$tsuki."-".$hi))].")"; ?></dt>
							<dd>
								<?php if (get_the_content() != "") { ?><a href="<?php the_permalink(); ?>"><?php the_title();?></a>
								<?php } else { ?><?php the_title();?>
								<?php } ?>
								<?php
									$days=7;
									$today=date('U'); $entry=get_the_time('U');
									$diff1=date('U',($today - $entry))/86400;
									if ($days > $diff1) {
								?>
									<img src="<?php bloginfo('stylesheet_directory'); ?>/img/common/new.gif" width="18" height="8" alt="new">
								
							</dd>
						<?php } ?>
						<?php
								endwhile;
							elseif ( !$the_query->have_posts() ):
								echo("現在１件もありません。");
							endif;
						?>
					</dl>
<?php wp_reset_query(); ?>
