<?php
/*
 * Template Name: Blog Grid Style
 * 
 * 
 * */

$blog_title = meditest_get_option('blog_title');
$blog_breadcrumb = meditest_get_option('blog_breadcrumb_enable', true);

get_header();

?>

<?php if ($blog_breadcrumb == true) : ?>
	<!-- Blog Breadcrumb -->
	<div class="theme-breadcrumb__Wrapper theme-breacrumb-area">
		<div class="container">
			<div class="row justify-content-center">
				<div class="col-lg-12">

					<h1 class="theme-breacrumb-title">

						<?php if (!empty($blog_title)) {
							echo esc_html($blog_title);
						} else {
							echo esc_html_e('Blog Page', 'meditest');
						} ?>
					</h1>
					<div class="breaccrumb-inner">
						<?php
						if (function_exists('the_meditest_breadcrumb')) {
							the_meditest_breadcrumb();
						}
						?>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- Blog Breadcrumb End -->
<?php endif; ?>

<section id="main-content" class="blog main-container blog-spacing" role="main">
	<div class="container">
		<div class="row">
			<div class="<?php if (is_active_sidebar('sidebar-1')) {
							echo "col-lg-9";
						} else {
							echo "col-lg-12";
						} ?> col-md-12">
				<div class="category-layout-two main-blog-layout blog-new-layout theme-layout-mainn">
					<?php if (have_posts()) : ?>

						<div class="theme-post-grid-design-one grid-loadmore-content news_post_trending_list post-trending-list-wrap post-list-medium-wrap post-list-medium-style post-medium-style-loadmore">

							<div class="row">

								<?php

								$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
								$query = new WP_Query(array(
									'post_type'      => 'post',
									'posts_per_page' => 10,
									'paged'          => $paged,
								));

								while ($query->have_posts()) : $query->the_post(); ?>

									<div class="col-md-4">

										<div class="post-block-item-one post-block-col-one meditest-post-grid pg_style_two">

											<div class="news-post-grid-thumbnail pg_two_img">
												<a href="<?php the_permalink(); ?>" class="news-post-grid-thumbnail-wrap">
													<img src="<?php echo esc_attr(esc_url(get_the_post_thumbnail_url(null, 'full'))); ?>" alt="<?php the_title_attribute(); ?>">
												</a>
											</div>

											<div class="news-post-grid-content grid-content-inner pg_two_content pg_content_three">

												<div class="grid-content-meta-uniq">
													<div class="custom-meta-date-bx">
														<i class="icon-calendar1"></i> <?php echo esc_html(get_the_date('d M, Y')); ?>
													</div>

													<h4 class="post-author-name">
														<?php echo esc_html('By', 'meditest-extra') . ' ' . get_the_author_link(); ?>
													</h4>

												</div>


												<h3 class="post-title">
													<a href="<?php the_permalink(); ?>"><?php echo esc_html(get_the_title()); ?></a>
												</h3>




											</div>

										</div>



									</div>

								<?php endwhile; ?>

							</div>
						</div>

						<div class="theme-pagination-style custom-paging-style">
							<?php

							// Pagination
							$big = 999999999; // need an unlikely integer

							echo paginate_links(array(
								'base'    => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
								'format'  => '?paged=%#%',
								'current' => max(1, get_query_var('paged')),
								'total'   => $query->max_num_pages,
							));

							// Reset post data
							wp_reset_postdata();

							?>
						</div>

					<?php else : ?>
						<?php get_template_part('template-parts/content', 'none'); ?>
					<?php endif; ?>

				</div>
			</div>

			<?php get_sidebar(); ?>

		</div>
	</div>
</section>

<?php get_footer();
