<?php
/**
 * The template for displaying all the posts
 *
 * @package ClubFitness
 */

?>
<div class="posts">
	<div class="row">
<?php $clubfitness_i = 1; ?>
<?php if ( have_posts() ) : ?>
	<?php while ( have_posts() ) : ?>
		<?php the_post(); ?>
		<?php if ( 1 === $clubfitness_i ) : ?>
		<div class="col-12 col-md-6 col-lg-12 col-xl-5 mb-4">
		<?php elseif ( 2 === $clubfitness_i ) : ?>
		<div class="col-12 col-md-6 col-lg-12 col-xl-7 mb-4">
		<?php else : ?>
		<div class="col-12 col-md-6 col-lg-12 col-xl-6 mb-4">
		<?php endif; ?>
			<div id="post-<?php the_ID(); ?>" <?php post_class( 'h-100' ); ?>>
				<?php $clubfitness_backgroundimg = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium_large' ); ?>
				<?php if ( 2 === $clubfitness_i ) : ?>
					<?php if ( has_post_thumbnail() ) : ?>
						<div class="post-item post-item-<?php echo esc_attr( $clubfitness_i ); ?> h-100 position-relative" style="background-image: url('<?php echo esc_url( $clubfitness_backgroundimg[0] ); ?>');">
					<?php else : ?>
						<div class="post-item post-item-<?php echo esc_attr( $clubfitness_i ); ?> h-100 position-relative">
					<?php endif; ?>
				<?php else : ?>
				<div class="post-item post-item-<?php echo esc_attr( $clubfitness_i ); ?> h-100 position-relative">
				<?php endif; ?>
				<?php if ( has_post_thumbnail() ) : ?>
					<?php if ( 1 !== $clubfitness_i && 2 !== $clubfitness_i ) : ?>
					<div class="post-image position-relative">
						<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
							<?php the_post_thumbnail( 'medium_large' ); ?>
							<span class="position-absolute bg-white rounded-circle text-center">...</span>
						</a>
					<?php endif; ?>
				<?php endif; ?>
					<?php if ( has_post_thumbnail() ) : ?>
						<div class="post-categories-list position-absolute p-4">
					<?php else : ?>
						<div class="post-categories-list">
					<?php endif; ?>
							<?php echo wp_kses_post( get_the_category_list() ); ?>
						</div>
				<?php if ( has_post_thumbnail() ) : ?>
					<?php if ( 1 !== $clubfitness_i && 2 !== $clubfitness_i ) : ?>
					</div>
					<?php endif; ?>
				<?php endif; ?>
				<?php if ( 1 === $clubfitness_i || 2 === $clubfitness_i ) : ?>
					<div class="post-info w-100 position-absolute p-4">
				<?php else : ?>
					<div class="post-info p-4">
				<?php endif; ?>
						<div class="post-title">
							<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
						</div>
						<?php get_template_part( 'inc/post', 'meta' ); ?>
					<?php if ( 1 !== $clubfitness_i ) : ?>
						<div class="post-message">
							<?php the_excerpt(); ?>
						</div>
					<?php endif; ?>
					</div>
				</div>
			</div>
		</div>
		<?php $clubfitness_i++; ?>
	<?php endwhile; ?>
<?php else : ?>
	<?php get_template_part( 'no-results' ); ?>
<?php endif; ?>
	</div>
</div>
<div class="page-nav">
	<?php the_posts_pagination(); ?>
</div>
