<?php get_header('employment'); ?>
<main>
    <?php include('template/bottom-blog.php'); ?>
    <?php include('template/breadcrumb.php'); ?>
    <section class="p-blog">
        <div class="p-blog__posts p-blog__posts--taxonomy">
            <div class="p-blog__inner l-inner">
                <p class="p-blog__entitle c-entitle c-entitle--capitalize">post list</p>
                <h2 class="p-blog__title c-title">検索:<?php echo get_search_query(); ?></h2>
                <div class="p-blog__container">
                    <div class="p-blog__contents">
                        <?php
                        if (have_posts()) :
                        if(function_exists('wp_pagenavi')) {
                            wp_pagenavi();
                        }
                        ?>
                        <div class="p-blog__archivePosts">
                            <?php while(have_posts()): the_post(); ?>
                                <div class="p-blog__item p-item p-item--content">
                                    <a href="<?php the_permalink(); ?>" class="p-item__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-item__body">
                                        <div class="p-item__info">
                                            <time class="p-item__time" datetime="<?php the_time('c'); ?>"><?php the_time( 'Y年m月d日' ); ?></time>
                                            <?php
                                            $terms = get_the_terms($post->ID, 'blog-cat');
                                            if ( $terms ) {
                                                echo '<div class="p-item__categories">';
                                                foreach ( $terms as $term ) {
                                                    echo '<a href="'.esc_url(get_term_link($term)).'" class="p-item__category">'.$term->name.'</a>';
                                                }
                                                echo '</div>';
                                            }
                                            ?>
                                        </div>
                                        <h3 class="p-item__title"><?php the_title(); ?></h3>
                                        <p class="p-item__text"><?php remove_filter('the_excerpt', 'wpautop'); the_excerpt();?></p>
                                    </div>
                                </div>
                            <?php endwhile; ?>
                        </div>
                        <?php
                        if(function_exists('wp_pagenavi')) {
                            echo '<div class="pagenavi-bottom">';
                            wp_pagenavi();
                            echo '</div>';
                        }
                        ?>
                        <?php else: ?>
                            <p class="p-products__noResults">検索されたキーワード「<?php echo get_search_query(); ?>」にマッチする記事はありませんでした。</p>
                        <?php
                        endif;
                        wp_reset_postdata();
                        ?>
                    </div>
                    <div class="p-blog__sidebar">
                        <?php include('template/sidebar.php'); ?>
                    </div>
                </div>
            </div>
        </div>
    </section>
</main>
<?php get_footer('employment');