<?php
/*
Template Name: 週報用
*/
?>
<?php get_header(); ?>

			<section class="clearfix">
				<h1>週報</h1>
				<div id="w_report" class="clearfix">
			<a href="<?php echo home_url('/'); ?>weekly-report/?category[3]=3&category[6]=6&category[5]=5">2020年7月第1週</a><br>
			<a href="<?php echo home_url('/'); ?>weekly-report/?category[3]=3&category[4]=4&category[5]=5">2020年6月第1週</a>
				
<?php
	if (!empty($_GET['category'])){
		$cate = $_GET['category'];
		if(is_array($cate)) {
			echo '<h2>';
			foreach ($cate as $val) {
				$p_term = get_term_by('id', $val, 'category');
				$cate_s[] = $p_term->term_id ;
				echo $p_term->name;
				if ($val !== end($cate)) {
					
				} else {
					echo ' 週報';
				}
			}
			echo '</h2>';
		} else {
		}
	}
?>
				<?php if (!empty($cate)){ ?>
					<?php if(is_array($cate)) { ?>
						<?php query_posts( array( 'category__and' => $cate_s, 'orderby' => 'name', 'order' => 'ASC' ) ); ?>
						<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
						<div>
							<h4><?php echo get_the_title() ;?></h4>
							<p><?php echo the_content(); ?></p>
						</div>
						<?php endwhile; endif; ?>
						<?php wp_reset_query(); ?>
					<?php } ?>
				<?php } ?>

				</div>
			</section>
						
<?php get_footer(); ?>
