<?php

/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Doctors Profile
 */
$doctors_profile_categories = get_the_category();
if ($doctors_profile_categories) {
	$doctors_profile_category = $doctors_profile_categories[mt_rand(0, count($doctors_profile_categories) - 1)];
} else {
	$doctors_profile_category = '';
}
?>
<div class="col-lg-4 mb-4">
	<article id="post-<?php the_ID(); ?>" <?php post_class('doctors-profile-list-item'); ?>>
		<div class="grid-blog-item">
			<div class="grid-top">
				<?php if (has_post_thumbnail()) : ?>
					<div class="grid-top-img">
						<a class="pkg-iconlink" href="<?php the_permalink(); ?>">
							<?php the_post_thumbnail('thumbnail'); ?>
						</a>
					</div>
					<div class="grid-top-title">
					<?php else : ?>
						<div class="grid-top-title no-img">
						<?php endif; ?>
						<?php the_title('<h2 class="grid-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h2>'); ?>
						</div>
					</div>
					<div class="grid-date">
						<p><?php echo esc_html(get_the_date('M j, Y')); ?></p>
					</div>
					<div class="grid-deatls p-3">
						<?php the_excerpt(); ?>
						<?php if ('post' === get_post_type() && !empty($doctors_profile_category)) : ?>
							<div class="grid-cat-author">
								<a class="blog-categrory" href="<?php echo esc_url(get_category_link($doctors_profile_category)); ?>"><?php echo esc_html($doctors_profile_category->name); ?></a>
								<span class="authorby">
									<?php doctors_profile_posted_by(); ?>
								</span>
							</div>
						<?php endif; ?>
					</div>
			</div>
	</article><!-- #post-<?php the_ID(); ?> -->
</div>