<?php get_header(); ?>
<?php global $qaleb;?>
<?php if($qaleb['media-slider'] == '1'){ ?>
<div class="main_videos">
<div class="container">
<div class="postlist clearfix">
  <?php
			  
			  if($qaleb['media-content']=='1'){
				$arggs = array(
					'post_type' => 'media',
					'posts_per_page' => 1,
				);
			  }else if($qaleb['media-content']=='2'){
				$arggs = array(
					'post_type' => 'media',
					'posts_per_page' => 1,
					'orderby'	=> 	'rand'
				);
			  }else if($qaleb['media-content']=='3'){
				$arggs = array(
					'post_type' => 'media',
					'posts_per_page' => 1,
					'tax_query' => array(
                        array(
                            'taxonomy' => 'media_category',
                            'field'    => 'term_id',
                            'terms'    => $qaleb['media-type-select'],
                        ),
				    ),
				);
			  }
			  
            query_posts($arggs);
            if(have_posts()) : while(have_posts()) : the_post(); ?>	
<?php
if(get_post_meta( get_the_ID(), 'href-link-player', true )!=null){
$video_link = get_post_meta( get_the_ID(), 'href-link-player', true );
}
?>
<?php
if($video_link==""&&$video_code!=""){
echo htmlspecialchars_decode($video_code);
}else if($video_link!=""){
?>			
<div class="item clearfix" style="background: none;">
<div class="head-video">
<section class="video">
<video poster="<?php the_post_thumbnail_url(''); ?>" controls>
<source src="<?php echo $video_link; ?>" type="<?php echo 'video/'.pathinfo($video_link, PATHINFO_EXTENSION);?>">
</section>
<?php

} ?>
</div>
</div>
<?php endwhile; endif;  wp_reset_query(); ?>

<?php
			  
			  if($qaleb['media-content']=='1'){
				$arggs = array(
					'post_type' => 'media',
					'posts_per_page' => 4,
					'offset' => 1,
				);
			  }else if($qaleb['media-content']=='2'){
				$arggs = array(
					'post_type' => 'media',
					'posts_per_page' => 4,
					'offset' => 1,
					'orderby'	=> 	'rand'
				);
			  }else if($qaleb['media-content']=='3'){
				$arggs = array(
					'post_type' => 'media',
					'posts_per_page' => 4,
					'offset' => 1,
					'tax_query' => array(
                        array(
                            'taxonomy' => 'media_category',
                            'field'    => 'term_id',
                            'terms'    => $qaleb['media-type-select'],
                        ),
				    ),
				);
			  }
			  
            query_posts($arggs);
            if(have_posts()) : while(have_posts()) : the_post(); ?>
<div class="item clearfix">
<div class="thumbnail">
<?php if(has_post_thumbnail()){?>
<a href="<?php the_permalink(); ?>"><img src="<?php the_post_thumbnail_url('post'); ?>" alt="<?php the_title(); ?>"><span class="play-icon fa fa-play"></span></a>
<?php }else{ ?>
<img src="<?php bloginfo("template_url"); ?>/img/none.png">
<?php } ?>
</div>
<div class="det">
<h2><span><?php the_title(); ?></span></h2>
<div class="entry-box-tools">
<span><i class="fa fa-clock-o" aria-hidden="true"></i> <?php the_time('G:i');  ?></span>
<span><?php the_time(' d F Y ');  ?></span>
</div>
</div>
<a class="link" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"></a>
</div>
<?php endwhile; endif;  wp_reset_query(); ?>
</div>
</div>
</div>
<?php } ?>

<section class="ap_main">
<div class="container inn">
<div class="boxx">
<div class="tit">
<h4><span><?php the_archive_title(); ?></span></h4>
</div>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="mediaa">	
<div class="thumbnail">
<?php if(has_post_thumbnail()){?>
<a href="<?php the_permalink(); ?>"><img src="<?php the_post_thumbnail_url('loop'); ?>" alt="<?php the_title(); ?>"></a>
<?php }else{ ?>
<img src="<?php bloginfo("template_url"); ?>/img/none.png">
<?php } ?>
<span class="metaha medat"><i class="fa fa-clock-o" aria-hidden="true"></i> <?php the_time('d F Y - G:i');  ?></span>
	<div class="mask-img"></div>
	<div class="meicon"><i class="fa fa-play"></i></div>
</div>
<h2><a href="<?php the_permalink(); ?>" alt="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
</div>
   <?php endwhile;
				else:
				echo "<b>چیزی یافت نشد !</b>";
				 endif; ?>
</div></div>			 
<div class="container inn"><?php numeric_posts_nav(); ?></div>	
</section>
<style>.marquee{background: #333;}.marquee-frame span a{color:#ddd !important}.main_videos{padding-top:30px;margin-top:-20px;margin-bottom:20px;}.content h1{margin-top:0;}</style>
<?php get_footer(); ?>