<?php
/**
 * The template for displaying archive pages.
 *
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package SociallyViral
 */

get_header(); ?>

	<div id="primary" class="content-archive">
		<main id="main" class="site-main" role="main">
            <header class="page-header">
				<?php
					sociallyviral_archive_title( '<h1 class="page-title">', '</h1>' );
					sociallyviral_archive_description( '<div class="taxonomy-description">', '</div>' );
				?>
			</header><!-- .page-header -->
			<div class="post-cards">
			<?php if ( have_posts() ) : 
				$j = 0; // counter
				while ( have_posts() ) : the_post();
            ?>
				<article id="post-<?php the_ID(); ?>" <?php post_class('latestpost'); ?>>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="nofollow" id="featured-thumbnail">
    				  <div class="featured-thumbnail">
    <?php 
    if (has_post_thumbnail()) {
        the_post_thumbnail($image_size, ['title' => '']);
    } else {
        $first_img = get_first_image_from_post(get_the_ID());
        if ($first_img) {
            echo '<img src="' . esc_url($first_img) . '" alt="' . esc_attr(get_the_title()) . '" />';
        } else {
            echo '<img src="' . sociallyviral_get_thumbnail_url($image_size == 'full' ? 'full' : 'full') . '" alt="' . esc_attr(get_the_title()) . '" />';
        }
    }
    ?>
</div>  <?php if($image_size == 'sociallyviral_featuredbig'){ ?>
							<div class="post-label"><i class="icon-star"></i><span><?php _e('Featured','sociallyviral'); ?></span></div>
						<?php } ?>
    				</a>
					<header class="entry-header">
						<?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
										</header><!-- .entry-header -->
				</article><!-- #post-## -->
			<?php endwhile; ?>
			</div>
				<?php wpbeginner_numeric_posts_nav(); ?>
		<?php else : ?>
			<?php get_template_part( 'content', 'none' ); ?>
		<?php endif; ?>
		</main><!-- #main -->
	</div><!-- #primary -->
<?php get_footer(); ?>
