<?php

/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Blog Grow
 */
$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 = '';
}
if (has_post_thumbnail()) {
	$BLOG_GROW_imgclass = 'nx-has-img';
} else {
	$BLOG_GROW_imgclass = 'nx-no-img';
}
?>

<article id="post-<?php the_ID(); ?>" <?php post_class('nx-list-item'); ?>>
	<div class="single-nx-list-item <?php echo esc_attr($BLOG_GROW_imgclass); ?>">
		<?php if (has_post_thumbnail()) : ?>
			<div class="nx-single-list-img">
				<a href="<?php the_permalink(); ?>">
					<?php the_post_thumbnail('medium_large'); ?>
				</a>
			</div>
		<?php endif; ?>
		<div class="nx-single-list-details">
			<?php if ($BLOG_GROW_category) : ?>
				<a href="<?php echo esc_url(get_category_link($BLOG_GROW_category)); ?>" class="nx-list-categories"><?php echo esc_html($BLOG_GROW_category->name); ?></a>
			<?php endif; ?>
			<?php the_title('<h2 class="nx-list-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h2>'); ?>
			<?php the_excerpt(); ?>
			<a class="blog-grow-readmore" href="<?php the_permalink(); ?>"><?php esc_html_e('READ MORE', 'blog-grow'); ?> <i class="fas fa-long-arrow-alt-right"></i></a>

		</div>
	</div>
</article><!-- #post-<?php the_ID(); ?> -->