File "archive-news.php"
Full path: /home/xs854402/smcse.co.jp/public_html/wp-content/themes/Sumitomo-Mitsui/archive-news.php
File
size: 5.82 B (5.82 KB bytes)
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php get_header(); ?>
<main class="corporate">
<?php include('template/bottom-corporate-news.php'); ?>
<?php include('template/breadcrumb.php'); ?>
<section class="p-archive">
<div class="p-archive__heading">
<div class="p-archive__inner l-inner">
<?php include('template/search.php'); ?>
<div class="p-archive__contents">
<?php
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$yearly = get_query_var('year');
$between = $year - $yearly;
$the_query = new WP_Query();
if($between == 7) :
$param = array(
'paged' => $paged,
'post_type' => 'news',
'posts_per_page' => '10',
'post_status' => 'publish',
'date_query' => array(
array(
'after' => array(
'year' => $yearly -100, // 現在の年
'month' => 4,
'day' => 1,
),
'before' => array(
'year' => $yearly, // 来年の年
'month' => 3,
'day' => 31,
),
'inclusive' => true,
),
),
);
else :
$param = array(
'paged' => $paged,
'year' => $yearly,
'post_type' => 'news',
'posts_per_page' => '10',
'post_status' => 'publish',
);
endif;
$the_query->query($param);
if ($the_query->have_posts()) :
echo '<div class="p-archive__posts">';
if(function_exists('wp_pagenavi')) {
echo '<div class="p-archive__pagenavi">';
wp_pagenavi(array('query'=>$the_query));
echo '</div>';
}
?>
<div class="p-archive__items">
<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="p-archive__item p-newsItem p-newsItem--archive">
<a href="<?php the_permalink(); ?>" class="p-newsItem__img c-img">
<?php
if (has_post_thumbnail()) :
the_post_thumbnail('post-thumbnail', array('alt' => the_title_attribute('echo=0')));
else :
echo '<img src="'.get_template_directory_uri().'/images/common/noimage.jpg" alt="'.esc_html(get_the_title()).'">';
endif; ?>
</a>
<div class="p-newsItem__body">
<div class="p-newsItem__info">
<time class="p-newsItem__time" datetime="<?php the_time( 'c' ); ?>"><?php the_time( 'Y.m.d' ); ?></time>
<?php
$terms = get_the_terms($post->ID, 'news-cat');
if ( $terms ) {
echo '<div class="p-newsItem__categories">';
$num = 0;
foreach($terms as $term) {
if($num <= 1) :
echo '<a href="'.esc_url(get_term_link($term)).'" class="p-newsItem__category">'.$term->name.'</a>';
endif;
$num++;
}
echo '</div>';
}
?>
</div>
<p class="p-newsItem__title"><?php the_title(); ?></p>
<p class="p-newsItem__text"><?php remove_filter('the_excerpt', 'wpautop'); the_excerpt();?></p>
<a href="<?php the_permalink(); ?>" class="p-newsItem__link">続きを読む</a>
</div>
</div>
<?php endwhile; ?>
</div>
<?php
if(function_exists('wp_pagenavi')) {
echo '<div class="p-archive__pagenavi p-archive__pagenavi--bottom">';
wp_pagenavi(array('query'=>$the_query));
echo '</div>';
}
?>
<?php
echo '</div>';
endif;
wp_reset_postdata();
?>
</div>
</div>
</div>
</section>
</main>
<?php get_footer();