<?php
/*
Template Name: ブログ一覧用
*/
?>
<?php if (is_user_logged_in()) { ?>

<?php get_header("members"); ?>

	<?php if (is_archive()) {
		if (!empty($_GET['category'])){
			$cate = $_GET['category'];
			if(is_array($cate)) {
				echo '<div class="page_title"><h2>';
				echo date('Y',get_post_time()) . '年';
				echo date('n',get_post_time()) . '月';
				foreach ($cate as $val) {
					$p_term = get_term_by('id', $val, 'category');
					$cate_s[] = $p_term->term_id ;
					echo $p_term->name;
				}
				echo '</h2></div>';
			} else {
			}
		}
	} else { ?>
		<div class="page_title">
			<h2><?php 
				$cat = get_the_category();
				$cat = $cat[0];
				echo $cat->cat_name;
			 ?></h2>
		</div>
	<?php } ?>

	<div id="contents">
		<?php get_sidebar(); ?>
		<article id="main">
			<section class="news_info page sclearfix">
				<ul class="news_info_ul">
					<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
						<li class="postList">
							<?php if (has_post_thumbnail()) { ?>
								<div class="postList_img">
									<a class="postList_thumbnail" href="<?php the_permalink(); ?>"><img src="<?php the_post_thumbnail_url( 'medium' ); ?>" width="60" height="50"></a>
								</div>
								<div class="postList_main">
									<p class="postList_time"><?php the_time('Y年n月j日'); ?>
									<?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/top/new.gif" width="18" height="12" alt="new" class="new-img">
									<?php } ?></p>
									<p class="postList_title"><a href="<?php the_permalink(); ?>"><?php the_title();?></a></p>
									<p class="postList_content"><a href="<?php the_permalink(); ?>"><?php the_excerpt(); ?></a></p>
								</div>
							<?php  } else { ?>
								<div class="postList_main_noimg">
									<p class="postList_time"><?php the_time('Y年n月j日'); ?>
									<?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/top/new.gif" width="18" height="12" alt="new" class="new-img">
									<?php } ?></p>
									<p class="postList_title"><a href="<?php the_permalink(); ?>"><?php the_title();?></a></p>
									<p class="postList_content"><a href="<?php the_permalink(); ?>"><?php the_excerpt(); ?></a></p>
								</div>
							<?php } ?>
						</li>
					<?php endwhile; endif; ?>
				</ul>
				<?php twentyfourteen_paging_nav(); ?>
				
			</section>
						
			<p id="pageTop"><a data-scroll href="#header"><br>page top</a></p>
		<!-- /main --></article>
	<!-- /contents --></div>

<?php get_footer("members"); ?>

<?php } else { ?>
	<?php get_header();?>
	<div class="page_title">
		<h2>404 page not found</h2>
	</div>
	<article id="main">
		<section>
			<p>お探しのページが見つかりません。</p>
		</section>
	</article>
	<?php get_footer(); ?>
<?php } ?>



