<?php
/**
 * The search template file
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * e.g., it puts together the home page when no home.php file exists.
 *
 * Learn more: {@link https://codex.wordpress.org/Template_Hierarchy}
 *
 * @package arcHIVE-theme
 * @since arcHIVE-theme 1.0.0
 */

get_header(); ?>

<?php get_template_part( 'template-parts/announcement' ); ?>

  <article>
    <main>
      <section class="search-results-content">
        <header>
          <h4>search results for:</h4>
          <h2>
            <span class="search-query-terms">
              <?php echo get_search_query( ); ?>
            </h2>
          </header>
          <aside class="hero hero-announcement resources">
              <?php dynamic_sidebar( 'announcement-resources-middle-widgets' ); ?>
          </aside>
          <main class="">
            <?php if ( have_posts() ) : ?>
            <?php while ( have_posts() ) : the_post(); ?>
            <article class="">
              <?php if ( has_post_thumbnail() ) :?>
                <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
                  <figure style="background-image: url(<?php echo get_the_post_thumbnail_url();?>);">
                  </figure>
                </a>
              <?php else :?>
                <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
                  <figure style="background-image: url(<?php echo catch_post_first_image();?>);">
                  </figure>
                </a>
              <?php endif;?>
              <h5 class="date">
                <?php //the_date('d.m.Y');?>
              </h5>
              <h3 class="entry-title">
                <a href="<?php the_permalink(); ?>" rel="bookmark">
                  <?php the_title(); ?>
                </a>
              </h3>
                <section class="excerpt post-excerpt">
                  <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
                    <?php the_excerpt() ?>
                </a>
              </section>
            </article>
            <?php endwhile;//end of the loop ?>
          </main>
          <?php //pagination here ?>
          <aside>
            <nav>
              <!--a href="" class="button hollow">see more news</a-->
            </nav>
          </aside>
        <?php else : //if no post in query ?>
          <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
        <?php endif; ?>

    </main>
  </article>
<?php get_footer();