<?php

if(have_posts()){
	?>
	<ul class="clearfix">
		<?php while( have_posts() ){
			the_post();
			$post_excerpt = kopa_get_the_excerpt_for_widget(get_the_excerpt(), get_the_content(), get_theme_mod('blog_excerpt', 55));
            $featured_content = get_post_meta(get_the_ID(),'single_post_featured_content',true);
            $post_format = get_post_format();
            $classes = array('entry-item');
            if(is_sticky( get_the_ID() )){
                array_push( $classes, 'sticky-post');
            }

			?>
			<li>
                <?php if('quote' == $post_format ){
                    $post_content = get_the_content();
                    if ( !empty($post_content) ) {
                        the_content();
                    } else {
                        echo '<blockquote><p>'. esc_html(get_the_title()) .'</p></blockquote>';
                    }
                ?>

                <?php } else{?>

                    <article <?php post_class($classes); ?>>
                    <?php
                    if(is_sticky( get_the_ID() )){
                        ?>
                        <span class="sticky-icon"></span>
                        <?php
                    }
                    ?>
                    <?php if( ! is_search() && has_post_thumbnail() ){ ?>
                    <div class="entry-thumb">
                        <?php get_template_part( 'library/templates/post-featured-content/content', $post_format ); ?>
                        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><div class="thumb-icon"></div></a>
                    </div>
                    <?php } ?>

                    <?php if(get_theme_mod('blog_date_status', 1) || get_theme_mod('blog_comment_status', 1) || get_theme_mod('blog_category_name_status', 1)){ ?>
                    <div class="entry-meta">
                        <?php if(get_theme_mod('blog_date_status', 1)){ ?>
                        <span class="entry-date"><?php echo get_the_date('F j,Y'); ?></span>
                        <?php } ?>
                        <?php if(get_theme_mod('blog_comment_status', 1)){ ?>
                        <?php if(comments_open() && !post_password_required()){ ?>
                            <span class="entry-comment"> / <?php comments_popup_link('No comment', '1 comment', '% comments'); ?></span>
                            <?php } ?>
                        <?php } ?>
                        <?php
                        $post_categories = wp_get_post_categories( get_the_ID() );
                        if( get_theme_mod('blog_category_name_status', 1) && $post_categories ){ ?>
                        <span class="entry-categories"> / <?php echo esc_html__('in:','garajez-lite'); ?> <?php the_category(', '); ?></span>
                        <?php } ?>
                    </div>
                    <?php } ?>
                    <?php if(get_theme_mod('blog_title_status', 1)){ ?>
                    <h3 class="entry-title" itemscope="" itemtype="http://schema.org/Event"><a itemprop="name" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="kopa-search"><?php the_title(); ?></a></h3>
                    <?php } ?>
                    <?php if(get_theme_mod('blog_excerpt_status', 1)){ ?>
                    <?php if(!empty($post_excerpt)){ ?>
                        <p class="kopa-search"><?php echo esc_html($post_excerpt); ?></p>
                        <?php } ?>
                    <?php } ?>
                    <?php if(get_theme_mod('blog_readmore_status', 1)){ ?>
                    <a href="<?php the_permalink(); ?>" class="more-link"><?php echo esc_html__('Read more','garajez-lite'); ?></a>
                    <?php } ?>
                </article>

                <?php } ?>
            </li>

			<?php
		} ?>
	</ul>
	<?php
} else {
    ?>
        <h2 class="entry-title"><?php echo esc_html__('Nothing Found...', 'garajez-lite'); ?></h2>
<?php }

get_template_part('library/templates/template', 'pagination');
