<?php
/**
 * Template part for displaying posts
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package Ice Hockey Club
 */
?>

<article class="<?php echo has_post_thumbnail() ? 'has-post-thumbnail' : 'no-post-thumbnail'; ?>">
	<div id="featured-posts" class="post-box">
		<div class="posts-box">
			<?php if (has_post_thumbnail($post->ID)) { ?>
			<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail'); ?>
			<div class="img-container">
				<div class="img-posts" style="background-image: url(<?php echo $image[0]; ?>);"></div>
			</div>
			<?php } 
			else { ?>
			<div class="img-container">
				<div class="img-posts" style="background-image: url(<?php echo esc_url(get_template_directory_uri()."/assets/images/default.png")?>);"></div>
			</div>
			<?php } ?>
			<div class="content-container">
				<div class="date-auther">
					<time datetime="<?php echo get_the_date('c'); ?>" itemprop="datePublished"><i class="fas fa-calendar-alt"></i> <?php echo get_the_date(); ?></time>
					<?php $author_id=$post->post_author; ?>
					<p><i class="fas fa-user"></i> <?php echo the_author_meta( 'display_name' , $author_id ); ?></p>
				</div>
				<h4><a href="<?php the_permalink();?>"><?php the_title();?></a></h4>
				<div class="class-content">
					<?php
						$excerpt = ice_hockey_club_the_excerpt( 20 );
						echo wp_kses_post( wpautop( $excerpt ) );
					?>
				</div>
			</div>
		</div>
		<a class="button-content" href="<?php the_permalink(); ?>">
			<span>
			Read More
			</span>
			<i class="fas fa-long-arrow-alt-right"></i>
		</a>
	</div>
</article>