<?php
get_header();
$sidebar = is_active_sidebar('sidebar') ? true : false;
if ( $sidebar ) {
    $args['sizes'] = '(min-width: 1200px) 370px, (min-width: 992px) 300px, (min-width: 768px) 350px, (min-width: 576px) 470px, calc( 100vw - 70px )';
} else {
    $args['sizes'] = '(min-width: 1200px) 370px, (min-width: 992px) 300px, (min-width: 768px) 650px, (min-width: 576px) 470px, calc( 100vw - 70px )';
}
?>
<div class="main-content">
    <div class="search-header">
		<div class="content-text">            
			<?php
                $total = $wp_query->found_posts;
            ?>            
			<h1><span class="search-total"><?php echo esc_html($total); ?></span>&nbsp;<span><?php esc_html_e( 'results for', 'loza' ); ?>:&nbsp;</span><?php the_search_query(); ?></h1>
        </div>
	</div>
    <?php
    if ( have_posts() ) { ?>
        <div class="loza-blog blog-standard">
            <?php while ( have_posts() ) { ?>
                <?php the_post(); ?>
                <article <?php post_class( 'loza-box post' ); ?>>                    
                    <?php
                        $image_url = wp_get_attachment_url( get_post_thumbnail_id() );                                    
                        if ( $image_url ) {
                            ?>
                            <div class="post-thumbnails">
                                <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'full', $args ); ?></a>
                            </div>
                            <?php
                        }
                    ?>
                    <div class="post-details">                        
                        <?php if ( get_the_title() ) { ?>
                        <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                        <?php } ?>
                        <div class="entry-meta">
                            <a class="post-date" href="<?php the_permalink(); ?>"><?php echo get_the_date(); ?></a>
                        </div>
                        <div class="entry-excerpt">
                            <?php echo wp_trim_words( get_the_excerpt(), 30, '...' ); ?>
                        </div>
                    </div>
                </article>
            <?php } ?>
            <?php loza_site_pagination(); ?>
        </div><?php
    } else {
        get_template_part( 'template-parts/post', 'none' );
    }
    ?>
</div>
<?php

get_sidebar();

get_footer();

