<?php
/**
 * Template Name: Sidebar Right
 * Template Post Type: post
 *
 * Template for not displaying a right sidebar on single post
 *
 * @package luxuryconceptfree
 *
 *
 */


get_header(); ?>
	  
	<main id="content" class="main-content">	
	
		<?php if (have_posts()) :?><?php while(have_posts()) : the_post(); ?>

			<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

					<h1 class=""><?php the_title(); ?></h1>
					<p class=""><strong> <?php the_time(get_option( 'date_format' )) ?> - <?php the_category(','); ?></strong> </p>

					<?php the_post_thumbnail('luxuryconceptfree_big', array('class' => 'img-res mb-2','alt' => get_the_title())); ?>

					<div class="text-content">
						<?php the_content(esc_html__('Read More...', 'luxuryconceptfree'));?>
					</div>
					<?php wp_link_pages('pagelink=Page %'); ?>

					<div class="clearfix"></div>

					<hr class="mt-3 mb-3" />

					<?php $post_tags = wp_get_post_tags($post->ID); if(!empty($post_tags)) {?>
						<p class=""> <?php the_tags('', ', ', ''); ?> </p>
					<?php } ?>
	
					<?php comments_template(); ?>


						<?php /* Custom Loop (Related Posts) */

						$custom_loop = new WP_Query(array(
						'post_type' => 'post',
						'category__in' => wp_get_post_categories(get_the_ID()),
						'post__not_in' => array(get_the_ID()),
						'posts_per_page' => 3,
						'orderby' => 'date',
						));?>

						<div class="grid-flex related-post">

							<?php if ($custom_loop->have_posts()):?> 

							<div class="col-100">
								<h3 class="text-center text-2"><?php esc_html_e('Related Posts', 'luxuryconceptfree'); ?></h3>
							</div>

							<?php while ($custom_loop->have_posts()): $custom_loop->the_post();?>


							<div class="col-33">
								<div class="p-2">
									<a href="<?php the_permalink(); // link to post single page ?>">										
										<h3><?php the_title(); // display title of the post  ?></h3>
									</a>

									<p class="mb-1">
										<strong>
											<?php the_time(get_option( 'date_format' )); // display date of the post ?>
											- <?php the_category(' ');?>
											<?php $post_tags = wp_get_post_tags($post->ID);if (!empty($post_tags)) {?>
											<?php the_tags('- ', ',  ', '');?>
											<?php }?>
										</strong>
									</p>
									<a href="<?php the_permalink(); ?>">
									   <?php the_post_thumbnail('luxuryconceptfree_list', array('class' => 'img-res ', 'alt' => get_the_title())); // display featured image of the post  ?>
									</a>
								</div>
							</div>

							<?php wp_reset_postdata();?>
							<?php endwhile;endif;?>

						</div>
					
			</article>		

		<?php endwhile; ?>
	    <?php else : ?>

	<div class="col-100">
	        <p><?php esc_html_e('Sorry, no posts matched your criteria.', 'luxuryconceptfree'); ?></p>
	</div>

	    <?php endif; ?>

	</main>
	<div class="primary-sidebar"><?php get_sidebar( 'primary' ); ?></div>	

<?php get_footer(); ?>