<?php
/**
 * The template for displaying search results pages
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#search-result
 *
 * @package Glowify wp
 */

get_header();

$enable_archive_bg = glowify_wp_option('enable_archive_bg');

$blog_archive_bc_bg = glowify_wp_option('blog_archive_bc_bg');

if($blog_archive_bc_bg){
    $blog_archive_bc_src = wp_get_attachment_image_src($blog_archive_bc_bg['id'], 'full', false);
}


if (have_posts()) {
    $blog_row_resize = 'grid';
} else {
    $blog_row_resize = 'no-grid';
}

if (is_active_sidebar('glowify-blog-sidebar')) {
    $blog_sidebar_column = 'col-xxl-8 col-lg-8';
} else {
    $blog_sidebar_column = 'col-lg-10 offset-lg-1 col-md-10 offset-md-1';
}



?>

    <?php if ($enable_archive_bg == true) : ?>
    <div class="cs_height_40 cs_height_lg_30"></div>
    <div class="container">
      <div class="cs_breadcamp_wrap cs_style_1 cs_accent_light_bg cs_bg_filed cs_radius_8" 
        <?php if (!empty($blog_archive_bc_src) && is_array($blog_archive_bc_src) && !empty($blog_archive_bc_src[0])) : ?>
        data-src="<?php echo esc_url($blog_archive_bc_src[0]); ?>"
        <?php endif; ?>>
      
        <div>
        <h1 class="cs_breadcamp_title cs_fs_54 cs_semibold">
            <?php if ( have_posts() ) : ?>
                <?php printf( esc_html__( 'Search Results for: %s', 'glowify-wp' ), get_search_query() ); ?>
            <?php else : ?>
                <?php esc_html_e( 'Nothing Found', 'glowify-wp' ); ?>
            <?php endif; ?>

        </h1>
          <ol class="breadcrumb cs_fs_18 mb-0">
            <li class="breadcrumb-item"><a href="<?php echo esc_url(home_url('/')); ?>"><?php esc_html_e('Home','glowify-wp');?></a></li>
            <li class="breadcrumb-item active">
                <?php if ( have_posts() ) : ?>
                    <?php printf( esc_html__( 'Search Results for: %s', 'glowify-wp' ), get_search_query() ); ?>
                <?php else : ?>
                    <?php esc_html_e( 'Nothing Found', 'glowify-wp' ); ?>
                <?php endif; ?>
            </li>
          </ol>
        </div>
      </div>
    </div>
    <?php endif; ?>




<div class="glowify-internal-area news-area section-bg search-page glowify-blog-main-section glowify-blog-area">
    <div class="container">
        <div class="row">
            <div class="<?php echo esc_attr($blog_sidebar_column); ?> col-12">
                <div class="glowify-page-content glowify-blog-main-section__archive">
                    <div class="row <?php echo esc_attr($blog_row_resize); ?>">
                        <?php if (have_posts()) : ?>
                            <?php
                            /* Start the Loop */
                            while (have_posts()) :
                                the_post();
                                /**
                                 * Run the loop for the search to output the results.
                                 * If you want to overload this in a child theme then include a file
                                 * called content-search.php and that will be used instead.
                                 */
                                get_template_part('template-parts/content', 'search');
                            endwhile;
                        else :
                            get_template_part('template-parts/content', 'none');
                        endif;
                        ?>
                    </div>
                    <div class="row">
                        <div class="col-12">
                            <!-- Start Pagination -->
                            <div class="pagination-main">
                                <?php
                                if (function_exists("glowify_wp_pagination")) {
                                    glowify_wp_pagination();
                                }
                                ?>
                            </div>
                            <!--/ End Pagination -->
                        </div>
                    </div>
                </div>
            </div>
			<?php if (is_active_sidebar('glowify-blog-sidebar') ) :?>
            <div class="col-lg-4 col-12">
                <aside id="secondary" class="sidebar-main cs_right_sidebar">
                    <?php  get_sidebar();?>
                </aside>
            </div>
			<?php endif;?>
        </div>
    </div>
</div>

<?php get_footer(); ?>
