<?php
/**
 * Template part for displaying home team section
 *
 * @package Education_Soul
 */

?>
<?php
	$team_title    = education_soul_get_option( 'team_title' );
	$team_number   = education_soul_get_option( 'team_number' );
	$team_column   = education_soul_get_option( 'team_column' );
	$team_category = education_soul_get_option( 'team_category' );
?>
<div id="education-soul-team" class="home-section home-section-team">
	<div class="container">
		<h2 class="section-title"><?php echo esc_html( $team_title ); ?></h2>
		<?php
		$qargs = array(
			'posts_per_page'      => absint( $team_number ),
			'no_found_rows'       => true,
			'ignore_sticky_posts' => true,
			'meta_query'          => array(
				array(
					'key' => '_thumbnail_id',
				),
			),
		);

		if ( absint( $team_category ) > 0 ) {
			$qargs['cat'] = absint( $team_category );
		}

		// Fetch posts.
		$the_query = new WP_Query( $qargs );
		?>
		<?php if ( $the_query->have_posts() ) : ?>
			<div class="inner-wrapper team-wrapper teams-col-<?php echo absint( $team_column ); ?>">
				<?php
				while ( $the_query->have_posts() ) :
					$the_query->the_post();
					?>
					<div class="team-item">
						<div class="thumb-summary-wrap">
							<div class="team-item-inner">
								<div class="team-thumb">
									<?php if ( has_post_thumbnail() ) : ?>
										<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'education-soul-thumb' ); ?></a>
									<?php endif; ?>
								</div> <!-- .team-thumb -->
								<div class="team-text-wrap">
									<h3 class="team-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
								</div> <!-- .team-text-wrap -->

							</div><!-- .team-item-inner -->
						</div> <!-- .thumb-summary-wrap -->
					</div><!-- .team-item -->

				<?php endwhile; ?>
			</div><!-- .team-wrapper -->
			<?php wp_reset_postdata(); ?>

		<?php endif; ?>
	</div><!-- .container -->
</div><!-- .home-section-team -->
