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

?>
<?php
	$team_title    = university_hub_get_option( 'team_title' );
	$team_number   = university_hub_get_option( 'team_number' );
	$team_column   = university_hub_get_option( 'team_column' );
	$team_category = university_hub_get_option( 'team_category' );
?>
<div id="university-hub-team" class="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,
			'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( 'medium' ); ?></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 -->
