<?php
/**
 * Template part for displaying Recent Posts in the front page template
 *
 * @package Personal_Trainer
 */
?>
<div class="recent-blog-content-wrapper">
	<div class="wrapper">
		<div class="recent-blog-container">
			<?php
			$post_title = get_theme_mod( 'personaltrainer_recent_posts_heading', esc_html__( 'Recent Posts', 'personal-trainer' ) );

			if ( '' !== $post_title ) :
			?>
				<div class="section-heading-wrap">
					<h2 class="section-title"><?php echo esc_html( $post_title ); ?></h2>
				</div><!-- .section-heading-wrap -->
			<?php
			endif;
			?>
			<div class="section-content-wrap">
				<?php
				$recent_posts = new WP_Query( array(
					'ignore_sticky_posts' => true,
				) );

				/* Start the Loop */
				while ( $recent_posts->have_posts() ) :
					$recent_posts->the_post();
					?>
					<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
						<?php if ( is_sticky() ) { ?>
							<span class="sticky-label"><?php esc_html_e( 'Featured', 'personal-trainer' ); ?></span>
						<?php } ?>

						<figure class="entry-image">
							<?php
							if ( has_post_thumbnail() ) {
								the_post_thumbnail();
							} else {
								echo '<img src="' . trailingslashit( esc_url( get_template_directory_uri() ) ) . 'assets/images/no-thumb-480x364.jpg"/>';
							}
							?>
						</figure>

							<div class="entry-container">
								<header class="entry-header">
									<div class="entry-meta">
										<?php personaltrainer_posted_on(); ?>
									</div><!-- .entry-meta -->

									<?php the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); ?>
								</header><!-- .entry-header -->

								<div class="entry-content">
									<p><span class="more-button"><a class="more-link" href="<?php the_permalink(); ?>"><?php echo wp_kses_data( get_theme_mod( 'personaltrainer_excerpt_more_text',  esc_html__( 'Continue reading', 'personal-trainer' ) ) ); ?></a></span></p>
								</div><!-- .entry-content -->
							</div> <!-- .entry-container -->
						</article><!-- #post -->
					<?php
				endwhile;

				wp_reset_postdata();
				?>
			</div><!-- .section-content-wrap -->
			<p class="view-more"><a class="more-recent-posts button" href="<?php the_permalink( get_option( 'page_for_posts' ) ); ?>"><?php esc_html_e( 'More Posts', 'personal-trainer' ); ?></a></p>
		</div> <!-- .section -->
	</div> <!-- .wrapper -->
</div> <!-- .recent-blog-content-wrapper -->
