<?php
//固定ページで特定の投稿を取得し、ページ送りする
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$args = array(
'paged' => $paged,
'posts_per_page' => 10,
'post_type' => array( 'post' ),
'tag' => 'covid19'
);
$my_query = new WP_Query( $args );
if ( $my_query->have_posts() ) :
while ( $my_query->have_posts() ) : $my_query->the_post();
$category = get_the_category();
$cat_id = $category[0]->cat_ID;
$cat_name = $category[0]->cat_name;
$cat_slug = $category[0]->category_nicename;
?>
<a href="<?php the_permalink(); ?>">
<li class="item">
<span class="news-date"><?php the_time('Y.m.d'); ?></span>
<span class="news-category <?php echo $cat_slug;?>"><?php echo $cat_name; ?></span>
<span class="news-title"><?php the_title(); ?></span>
</li></a>
<?php endwhile; ?>
<?php else : //記事が無い場合 ?>
<li class="item">
<div class="title">
<h3>現在、表示する記事はありません。</h3>
</div>
</li>
<?php endif;?>
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(array('query' => $my_query)); } ?>
<?php wp_reset_postdata(); //クエリのリセット ?>
</ul>
</div>
</div><!--#covidnews-->