<?php

/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package RealEstate Press
 */
$realestate_press_categories = get_the_category();
if ($realestate_press_categories) {
	$realestate_press_category = $realestate_press_categories[mt_rand(0, count($realestate_press_categories) - 1)];
} else {
	$realestate_press_category = '';
}
?>
<article id="post-<?php the_ID(); ?>" <?php post_class('realestate-press-list-item'); ?>>
	<div class="realestate-press-item realestate-press-text-list shadow-sm mb-5 <?php if (has_post_thumbnail()) : ?>has-thumbnail<?php endif; ?>">
		<div class="row">
			<?php if (has_post_thumbnail()) : ?>
				<div class="col-lg-6">
					<a href="<?php the_permalink(); ?>">
						<?php the_post_thumbnail('medium_large'); ?>
					</a>
				</div>
				<div class="col-lg-6">
				<?php else : ?>
					<div class="col-lg-12 pb-3 pt-3">
					<?php endif; ?>
					<div class="realestate-press-text p-3">
						<div class="realestate-press-text-inner">
							<div class="grid-head">
								<span class="ghead-meta list-meta">
									<?php if ('post' === get_post_type() && !empty($realestate_press_category)) : ?>
										<a href="<?php echo esc_url(get_category_link($realestate_press_category)); ?>"><?php echo esc_html($realestate_press_category->name . ' / '); ?></a>
									<?php endif; ?>
									<?php echo esc_html(get_the_date()); ?>
								</span>
								<?php the_title('<h2 class="entry-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h2>'); ?>
								<?php if ('post' === get_post_type()) :
								?>
									<div class="list-meta list-author">
										<?php realestate_press_posted_by(); ?>
									</div><!-- .entry-meta -->
								<?php endif; ?>
								<?php the_excerpt(); ?>
							</div>
							<a class="realestate-press-readmore" href="<?php the_permalink(); ?>"><?php esc_html_e('Read More ', 'realestate-press'); ?></a>
						</div>
					</div>
					</div>
				</div>

		</div>
</article><!-- #post-<?php the_ID(); ?> -->