ÿØÿÛ C 

ÿØÿÛ C 

<?php
/**
 * Template Name: Blog Grid Right Sidebar
 */
get_header();
?>
<section id="post-section" class="post-section av-py-default">
	<div class="av-container" style="display:flex;">

		<!-- Classes for sidebar None -->
		<?php
		if ( ! is_active_sidebar( 'marin-sidebar-primary' ) ) {
			$div_classes = 'av-column-12 av-md-column-12';
		} else {
			$div_classes = 'av-column-8 av-md-column-8';
		}
		?>

		<div class="<?php echo esc_attr( $div_classes ); ?>">
			<div class="av-columns-area">

				<!-- blog-grid.php-->
					<?php
						$marin_paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
						$args        = array(
							'post_type' => 'post',
							'paged'     => $marin_paged,
						);

						$loop = new WP_Query( $args );
						if ( $loop->have_posts() ) :
							// Start the Loop.
							while ( $loop->have_posts() ) :
								$loop->the_post();
								// includelude the post format-specific template for the content.
								get_template_part( 'template-parts/content/content', 'grid' );
							endwhile;
							?>

							<!-- Custom Pagination -->
							<?php
							$big        = 999999999; // Set a big number to ensure all pages are included in the pagination links.
							$pagination = paginate_links(
								array(
									'base'      => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
									'format'    => '?paged=%#%',
									'current'   => max( 1, get_query_var( 'paged' ) ),
									'total'     => $loop->max_num_pages,
									'prev_text' => '<i class="fa fa-angle-double-left"></i>',
									'next_text' => '<i class="fa fa-angle-double-right"></i>',
									'type'      => 'array', // Generate an array of links.
								)
							);

							if ( $pagination ) :
								?>
								<nav class="navigation pagination" aria-label="Posts">
									<h2 class="screen-reader-text">Posts navigation</h2>
									<div class="nav-links">
										<?php
										foreach ( $pagination as $page_link ) {
											echo $page_link;
										}
										?>
									</div>
								</nav>
							<?php endif; ?>
							<!-- Custom Pagination -->


					<?php else : ?>
						<?php get_template_part( 'template-parts/content/content', 'none' ); ?>
					<?php endif; ?>
			</div>
		</div>

		<?php
		if ( is_active_sidebar( 'marin-sidebar-primary' ) ) {
			?>
			<!--Sidebar Right -->
			<div id="av-secondary-content" class="av-column-area">
				<section class="sidebar">
				<?php dynamic_sidebar( 'marin-sidebar-primary' ); ?>
				</section>
			</div>
			<!--/Sidebar Right-->
		<?php } ?>
	</div>
</section>
<?php get_footer(); ?>
