<?php

/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Blog Grow
 */
$BLOG_GROW_blog_layout = get_theme_mod('BLOG_GROW_blog_layout', 'rightside');
if ($BLOG_GROW_blog_layout == 'fullwidth' || !is_active_sidebar('sidebar-1')) {
	$BLOG_GROW_grid = 4;
} else {
	$BLOG_GROW_grid = 6;
}
$BLOG_GROW_categories = get_the_category();
if ($BLOG_GROW_categories) {
	$BLOG_GROW_category = $BLOG_GROW_categories[mt_rand(0, count($BLOG_GROW_categories) - 1)];
} else {
	$BLOG_GROW_category = '';
}
?>
<div class="col-lg-<?php echo esc_attr($BLOG_GROW_grid); ?> grid-item mb-5">

	<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
		<div class="grid-item-post">
			<?php if (has_post_thumbnail()) : ?>
				<div class="grid-item-img">
					<a class="grid-item-img-link" href="<?php the_permalink(); ?>">
						<?php the_post_thumbnail('full'); ?>
					</a>
				</div>
			<?php endif; ?>

			<div class="grid-item-details">
				<?php if ($BLOG_GROW_category) : ?>
					<a class="cat-noimg-top" href="<?php echo esc_url(get_category_link($BLOG_GROW_category)); ?>"><?php echo esc_html($BLOG_GROW_category->name); ?></a>
				<?php endif; ?>
				<?php the_title('<h2 class="grid-item-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h2>'); ?>
				<?php the_excerpt(); ?>
				<div class="grid-bottom">
					<?php if ('post' === get_post_type()) : ?>
						<div class="entry-meta">
							<?php BLOG_GROW_posted_by(); ?>
						</div><!-- .entry-meta -->
					<?php endif; ?>
					<span class="reding-time"><?php echo BLOG_GROW_content_reading_time(); ?></span>
				</div>
			</div>
		</div>
	</article><!-- #post-<?php the_ID(); ?> -->

</div>