<?php 

    global $post;

    $relatedposts = get_posts( array( 
	
	'category__in' => wp_get_post_categories($post->ID), 
	'numberposts' => 3,
	'order'       => 'ASC',
	'post__not_in' => array($post->ID) ) 
	
	);
	
    if( $relatedposts ) : 

    echo '<div class="theme_related_post_Grid">';
    echo '<h2>'.esc_html__( 'Related Posts', 'meditest' ).'</h2>';
	
    echo '<div class="theme_post_grid__Slider_Wrapperr">';
	echo '<div class="theme_post_grid__Slider related-posts-slider row">';
	
	
    foreach( $relatedposts as $post ) {
		
    setup_postdata($post); ?>
    
	
<div class="col-lg-4 col-sm-12">	
	<div class="post-block-item-one post-block-col-one post-item-style-one">
		
		<div class="news-post-grid-thumbnail">
			<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">
			<h3 class="post-title">
				<a href="<?php the_permalink(); ?>"><?php echo esc_html( wp_trim_words(get_the_title(), 100,'') ); ?></a>
			</h3>
			<div class="post-meta-bottom-list-wrap cols-post-meta-items">
				<div class="post-meta-left-wrap cols-meta-left">
				
					<div class="post-meta-left-author">
						<?php echo get_avatar( get_the_author_meta( 'ID' ), 48 ); ?>
					</div>
					
					<div class="post-meta-left-content">
						<h4 class="post-author-name">
							<?php echo get_the_author_link(); ?>
						</h4>
						<ul class="post-bottom-meta-list">
							<li class="post-meta-date"><?php echo esc_html( get_the_date( 'F j, Y' ) ); ?></li>
						</ul>
					</div>
				</div>
			</div>
		</div>
	</div>
	
</div>	
	
    <?php } 
	
	wp_reset_postdata();

    echo '</div>'; 
	echo '</div>';
    echo '</div>';

    endif;