<?php 
	//for use in the loop, list 2 post titles related to first tag on current post
	$tags = wp_get_post_tags(get_the_ID());
	if ( $tags || wp_get_post_categories(get_the_ID()) ) {
		$tag_ids = array();
		foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
		$args=array(
			'tag__in' => $tag_ids,
			'post__not_in' => array(get_the_ID()),
			'category__in' => wp_get_post_categories(get_the_ID()),
			'posts_per_page'=> 2
		);
		$my_query = new WP_Query($args);
		if( $my_query->have_posts() ) {
?>
<div class="related-posts"> <!-- Lists of Related Posts -->
	<div class="section-title">
		<h4 class="title"><?php rst_the_translate('Related Posts','translation_related_post') ?></h4>
	</div>
	<div class="row">	
		<?php
			while ($my_query->have_posts()) : $my_query->the_post();
		?>
		<div class="col-md-6">
			<div class="media">
				<?php if( get_post_thumbnail_id($post->ID) ) { ?>
				<div class="media-left">
					<a href="<?php the_permalink() ?>">
						<img src="<?php echo bfi_thumb(wp_get_attachment_url(get_post_thumbnail_id($post->ID)),array('width' => 80,'height'=>80)) ?>" alt="" />
					</a>
				</div>
				<?php } ?>
				<div class="media-body">
					<h4 class="media-heading"><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h4>
					<?php 
						echo get_excerpt_by_id($post,15 );
					?>
					<a class="meta-date" href="<?php echo get_day_link(get_post_time('Y'), get_post_time('m'), get_post_time('j')); ?>"><?php echo mysql2date('d F Y', $post->post_date) ?></a>
				</div>
			</div>
		</div>
	<?php
		endwhile;
	?>	
	</div>
</div>
<?php
		}
		wp_reset_query();
	}
?>
