<?php
/**
 * The main template for archive pages.
 *
 * Learn more: https://developer.wordpress.org/themes/basics/template-hierarchy/
 * @since 1.0
 * @package evaWp
 */
get_header();
?>
<div class="container" id="site-content">
	<div class="row">
		<div class="<?php echo esc_attr( evawp_is_sidebar_active() ? 'col-md-8 col-lg-8' : 'col-md-12' ); ?> content-wrapper">
			<main id="main" class="site-main ">
				<?php if ( have_posts() ): ?>
					<div class="row" id="evawp-main-content">
						<?php
						# Load posts loop.
						while ( have_posts() ) : the_post(); 
						?>
							<div class="<?php evawp_the_post_per_row_class(); ?>">
								<?php get_template_part( 'templates/content/content', '' ); ?>
							</div>
						<?php endwhile; ?>
					</div>
					<div class="evawp-archive-pagination-wrapper">						
						<?php 
						$pagination_format = evawp_customizer_get( 'pagination_format', 'number' );
						if( 'number' == $pagination_format ){
							the_posts_pagination(
								array(
									'prev_text' => esc_html__( 'Previous', 'evawp' ),
									'next_text' => esc_html__( 'Next', 'evawp' ),
								)
							); 
						}elseif( 'loadmore' == $pagination_format ){							
							$total_post = $wp_query->found_posts;
							$displayed_post = $wp_query->post_count;
							if( $displayed_post < $total_post ){
								echo '<a href="#" class="evawp-load-more">' . evawp_customizer_get( 'loadmore_post_text', esc_html__( 'Load More', 'evawp' ) ) . '</a>';
							}
						}

		
						?>		
					</div>
				<?php else: ?>
					<?php
						# If no content, include the "No posts found" template.
						get_template_part( 'templates/content/content', 'none' );
					?>
				<?php endif; ?>	
			</main>
		</div>
		<?php if( evawp_is_sidebar_active() ):?>
			<div class="col-md-4 col-lg-4 sidebar-wrapper">
				<?php get_sidebar(); ?>
			</div>
		<?php endif; ?>
	</div>	
</div>
<?php get_footer() ?>