<?php
/**
 * Template part for displaying posts
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package Luxury Hotels
 * @subpackage luxury_hotels
 */

?>
<article class="col-lg-4 col-md-6">
	<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
		<div class="page-box">
	        <div class="box-image ">
	            <?php the_post_thumbnail();  ?>
	        </div>
		    <div class="box-content text-center">
		    	<h4><a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php the_title_attribute(); ?>"><?php the_title();?></a></h4>
		        <div class="box-info">
				    <?php 
				    // Add 'time' to your default meta order array
				    $luxury_hotels_blog_archive_ordering = get_theme_mod('blog_meta_order', array('date', 'author', 'comment', 'category', 'time'));

				    foreach ($luxury_hotels_blog_archive_ordering as $luxury_hotels_blog_data_order) : 
				        if ('date' === $luxury_hotels_blog_data_order) : ?>
				            <i class="far fa-calendar-alt mb-1"></i>
				            <a href="<?php echo esc_url(get_day_link(get_the_date('Y'), get_the_date('m'), get_the_date('d'))); ?>" class="entry-date">
				                <?php echo esc_html(get_the_date('j F, Y')); ?>
				            </a>
				        <?php elseif ('author' === $luxury_hotels_blog_data_order) : ?>
				            <i class="fas fa-user mb-1"></i>
				            <a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?>" class="entry-author">
				                <?php the_author(); ?>
				            </a>
				        <?php elseif ('comment' === $luxury_hotels_blog_data_order) : ?>
				            <i class="fas fa-comments mb-1"></i>
				            <a href="<?php comments_link(); ?>" class="entry-comments">
				                <?php comments_number(__('0 Comments', 'luxury-hotels'), __('1 Comment', 'luxury-hotels'), __('% Comments', 'luxury-hotels')); ?>
				            </a>
				        <?php elseif ('category' === $luxury_hotels_blog_data_order) : ?>
				            <i class="fas fa-list mb-1"></i>
				            <?php
				            $categories = get_the_category();
				            if (!empty($categories)) :
				                foreach ($categories as $category) : ?>
				                    <a href="<?php echo esc_url(get_category_link($category->term_id)); ?>" class="entry-category">
				                        <?php echo esc_html($category->name); ?>
				                    </a>
				                <?php endforeach;
				            endif; 
				            ?>
				        <?php elseif ('time' === $luxury_hotels_blog_data_order) : ?>
				            <i class="fas fa-clock mb-1"></i>
				            <span class="entry-time">
				                <?php echo get_the_time(); ?>
				            </span>
				        <?php endif;
				    endforeach; ?>
				</div>
		        <p><?php echo esc_html( wp_trim_words( get_the_content(), get_theme_mod( 'luxury_hotels_excerpt_count', 35 ) ) ); ?></p>
	        	<?php if(get_theme_mod('luxury_hotels_remove_read_button',true) != ''){ ?>
		            <div class="readmore-btn">
		                <a href="<?php echo esc_url( get_permalink() );?>" class="blogbutton-small" title="<?php esc_attr_e( 'Read More', 'luxury-hotels' ); ?>"><?php echo esc_html(get_theme_mod('luxury_hotels_read_more_text',__('Read More','luxury-hotels')));?></a>
		            </div>
	        	<?php }?>
		    </div>
		    <div class="clearfix"></div>
		</div>
	</div>
</article>