<?php
/**
 * This template displays the archive loop.
 *
 * @package Organic Startup
 * @since Organic Startup 1.0
 */

?>

<?php if ( have_posts() ) : ?>

	<?php if ( ! is_category() ) { ?>
		<h1 class="archive-title"><?php the_archive_title(); ?></h1>
	<?php } ?>

<?php while ( have_posts() ) : the_post(); ?>
<?php $video = organic_startup_first_embed_media(); ?>

	<!-- BEGIN .post class -->
	<div <?php post_class( 'archive-holder' ); ?> id="post-<?php the_ID(); ?>">

		<!-- BEGIN .article -->
		<article class="article">

			<h2><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

			<?php if ( has_post_thumbnail() && wp_is_mobile() ) { ?>
				<a class="feature-img" href="<?php the_permalink(); ?>" rel="bookmark" title="<?php echo esc_attr( sprintf( esc_html__( 'Permalink to %s', 'organic-startup' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php the_post_thumbnail( 'startup-featured-medium' ); ?></a>
			<?php } elseif ( has_post_thumbnail() ) { ?>
				<a class="feature-img" href="<?php the_permalink(); ?>" rel="bookmark" title="<?php echo esc_attr( sprintf( esc_html__( 'Permalink to %s', 'organic-startup' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php the_post_thumbnail( 'startup-featured-large' ); ?></a>
			<?php } elseif ( ! empty( $video ) ) { ?>
				<div class="feature-img"><?php echo $video ?></div>
			<?php } ?>

			<!-- BEGIN .post-meta -->
			<div class="post-meta">

				<div class="post-author">
					<p><?php esc_html_e( 'By', 'organic-startup' ); ?> <span class="author vcard"><?php esc_url( the_author_posts_link() ); ?></span></p>
				</div>

				<div class="post-date">
					<p><?php organic_startup_posted_on(); ?></p>
				</div>

			<!-- END .post-meta -->
			</div>

			<?php the_excerpt(); ?>

			<?php $tag_list = get_the_tag_list( esc_html__( ', ', 'organic-startup' ) ); if ( ! empty( $tag_list ) || has_category() ) { ?>

				<!-- BEGIN .post-meta -->
				<div class="post-meta">

					<!-- BEGIN .post-taxonomy -->
					<div class="post-taxonomy">

						<p class="align-left"><?php esc_html_e( 'Category:', 'organic-startup' ); ?> <?php the_category( ', ' ); ?><p>
						<?php if ( ! empty( $tag_list ) ) { ?>
							<p class="align-right"><?php esc_html_e( 'Tags:', 'organic-startup' ); ?> <?php the_tags( '' ); ?></p>
						<?php } ?>

					<!-- END .post-taxonomy -->
					</div>

				<!-- END .post-meta -->
				</div>

			<?php } ?>

		<!-- END .article -->
		</article>

	<!-- END .post class -->
	</div>

<?php endwhile; ?>

<?php the_posts_pagination( array(
	'prev_text' => '<span class="meta-nav screen-reader-text">' . esc_html__( 'Previous Page', 'organic-startup' ) . ' </span>&laquo;',
	'next_text' => '<span class="meta-nav screen-reader-text">' . esc_html__( 'Next Page', 'organic-startup' ) . ' </span>&raquo;',
) ); ?>

<?php else : ?>

	<!-- BEGIN .page-holder -->
	<div class="page-holder">

		<!-- BEGIN .article -->
		<article class="article">

			<?php get_template_part( 'content/content', 'none' ); ?>

		<!-- END .article -->
		</article>

	<!-- END .page-holder -->
	</div>

<?php endif; ?>
