<?php
/**
 * The template for displaying screen views section
 *
 * @package Oginer
 */

$screen_id = get_theme_mod( 'oginer_screen_id', 'screenviews' );
$screen_page = get_theme_mod( 'oginer_screen_page' );
?>

<section id="<?php echo esc_attr( $screen_id ); ?>" class="mw-section screenviews">
	<div class="container">
		<?php if ( $screen_page ) { ?>
			<div class="row">
				<div class="col-md-10 col-md-offset-1 text-center">
					<?php
						$args = array(
							'page_id' => absint( $screen_page ),
							'post_status' => 'publish'
						);

						$post_query = new WP_Query( $args );
						
						if( $post_query->have_posts() ): ?>
							<?php while ( $post_query->have_posts() ) : $post_query->the_post(); ?>
							
								<h2 class="section-title"><?php the_title(); ?></h2>
								
								<p><?php the_content(); ?></p>
								
								<?php  
							endwhile;
							
							wp_reset_postdata();
							
						endif; 
					?>
				</div>
			</div>
			<?php
		}
		?>
		<div class="row">
			<div class="col-md-12">
				<div class="screenviews-slider">
					<div class="bxslider">
						<?php
						for ( $i = 1; $i <= 6; $i++ ) { 
							$screen_img = get_theme_mod( 'oginer_screen_img_' . $i, get_template_directory_uri().'/img/screen'.$i.'.jpg' );
							$image_id = attachment_url_to_postid( $screen_img );
							$alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true );
							?>
							<div class="item">
								<img src="<?php echo esc_url( $screen_img  ); ?>" alt="<?php echo esc_attr( $alt ); ?>">
							</div>
						<?php 
						} ?>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>