<?php

	get_header();

	$jassHtml = '';

	$jassQueryArgs = array(
		'post_type' => 'post',
		'posts_per_page' => 6,
		'post__in'  => get_option( 'sticky_posts' ),
		'ignore_sticky_posts' => 1,
		'meta_query' => array(
			array(
				'key' => '_thumbnail_id',
				'compare' => 'EXISTS'
			)
		)
	);

	$jassQuery = new WP_Query($jassQueryArgs); 

	if ( $jassQuery->have_posts() ) : 

?>

		<div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="jass-carousel-wrapper">
                        <div class="owl-carousel jass-carousel">
                
							<?php
                            
                                while ( $jassQuery->have_posts() ) : $jassQuery->the_post(); 
                              
                                global $post;
                        
                                $jassThumbnailIMG = wp_get_attachment_image_src( get_post_thumbnail_id(), 'jass_carousel_thumbnail');
                                $jassThumbnailALT = (get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true )) ? get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true ) : get_the_title() ;
                        
                                $jassHtml .= '<div>';
                                $jassHtml .= '<img src="'.esc_url($jassThumbnailIMG[0]).'" alt="'.esc_attr($jassThumbnailALT).'">';
                                $jassHtml .= '<h3><a href="'.esc_url(get_the_permalink()).'">' . esc_attr(get_the_title()) . '</a></h3>';
                                $jassHtml .= '</div>';
                                endwhile;
                              
                                wp_reset_postdata();
                                
                                echo $jassHtml;
                        
                            ?>
                
                        </div>
					</div>
				</div>
			</div>
		</div>

<?php 
	
	endif;

?>

<div id="content" class="container">
  <div class="row">
    <div class="col-md-12">

      <?php

        if ( have_posts() ) :

          while ( have_posts() ) :

            the_post();
            get_template_part( 'template-parts/content' );

          endwhile;

        else:

          esc_html_e( 'Sorry, no post found.', 'jass' );

        endif;

        get_template_part( 'template-parts/pagination' );

      ?>

    </div>
  </div>
</div>

<?php

  get_footer();

?>
