<section class="popular-subjects">
	<div class="container">
		<h2 class="main-title-page">
			<span class="color-lilac">Популярные</span><br>
			<span class="color-black">предметы</span>
		</h2>
				
		<?php // параметры по умолчанию
				$posts = get_posts( array(
					'numberposts' => 3,
					'category'    => 0,
					'orderby'     => 'date',
					'order'       => 'DESC',
					'include'     => array(),
					'exclude'     => array(),
					'meta_key'    => '',
					'meta_value'  => '',
					'post_type'   => 'course',
					'suppress_filters' => true,
					'meta_key'		=> 'otobrazhat_v_poppulyarnyh',
					'meta_value'	=> 'yes'
				) ); ?>
		<div class="swiper swiper-popular-subjects">	
			<div class="swiper-wrapper">
			<?php foreach( $posts as $post ){ setup_postdata($post); ?>
				<a href="<?php the_permalink(); ?>" class="swiper-slide popular__subject">
					<div class="popular__subject_img">
						<?php $label = carbon_get_post_meta( $post->ID, 'box_label' ); 
							if ($label != "") :?>
								<span class="popular__subject_label"><?php echo $label; ?></span>
							<?php endif; ?>
						<?php $gallery = get_field('gallery'); ?>
						<?php if (!empty($gallery)) {?>
							<img src="<?php echo $gallery[0]['url']; ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>">  
						<?php } else {?>
							<img src="/wp-content/uploads/2021/02/podgotovka-k-oge-po-geografii.jpg" alt="<?php the_title(); ?>" title="<?php the_title(); ?>">
						<?php } ?>	
					</div>						
					<div class="product-info">
						<h3 class="popular__subject_title"><?php the_title(); ?></h3>
						<p class="popular__subject_text"><?php $informaciya_o_kurse = get_field('informaciya_o_kurse'); 
						echo wp_trim_words( $informaciya_o_kurse, 300, ' ...' ); 
						?></p>
					</div>
				</a>
			<?php } wp_reset_postdata(); ?>
			
			</div>
		</div>
		<div class="custom-button-next subject-next"></div>
		<div class="custom-button-prev subject-prev"></div>
		<div class="buttons">
			<a href="/cources/" class="btn-yellow-link">смотреть все предметы</a>
		</div>
	</div>
</section>