<?php
/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package NewsBox Plus
 */
$newsbox_plus_blog_layout = get_theme_mod( 'newsbox_plus_blog_layout', 'rightside' );
if($newsbox_plus_blog_layout == 'fullwidth' || !is_active_sidebar( 'sidebar-1' ) ){
	$newsbox_plus_grid = 4;
}else{
	$newsbox_plus_grid = 6;
}
$newsbox_plus_categories = get_the_category();
	if($newsbox_plus_categories){
		$newsbox_plus_category = $newsbox_plus_categories[mt_rand(0,count( $newsbox_plus_categories)-1)];
	}else{
		$newsbox_plus_category = '';
	}
?>
<div class="col-lg-<?php echo esc_attr($newsbox_plus_grid); ?> grid-item">
	<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
		<div class="newsboxg-item shadow pb-3 mb-5">
			<?php if( has_post_thumbnail() ): ?>
			<div class='nboxp-grimg'>
			<?php newsbox_plus_post_thumbnail(); ?>
			<?php if ( 'post' === get_post_type() && !empty($newsbox_plus_category) ): ?>
					<a class="nbox-grid-cat" href="<?php echo esc_url(get_category_link($newsbox_plus_category)); ?>"><?php echo esc_html($newsbox_plus_category->name); ?></a>
			<?php endif; ?>
			</div>
			<?php endif; ?>
			<div class="newsbox-plus-grid-text p-3">
				<div class="grid-head">
					<?php the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' ); ?>
				</div>
				<?php the_excerpt(); ?>
				<a class="xshop-readmore" href="<?php the_permalink(); ?>">
					<?php esc_html_e( 'Read More ','newsbox-plus'); ?> <i class="fas fa-long-arrow-alt-right"></i>
				</a>
						
			</div>
		</div>
	</article><!-- #post-<?php the_ID(); ?> -->
</div>
