<?php get_header(); ?>
<?php global $qaleb;?>
<?php if($qaleb['media-slider'] == '1'){ ?>
<div class="gallery-content">
<div class="container">
<div class="wrapper">
<?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(); ?>
<div class="player-right">
<?php if(get_post_meta( get_the_ID(), 'href-link-player', true )!=null){ ?>
<video poster="<?php the_post_thumbnail_url('loop-3'); ?>" src="<?php echo get_post_meta( get_the_ID(), 'href-link-player', true ); ?>" data-overlay="1"></video> 
<?php } ?>
</div>

<div class="player-left">
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<p><?php if(get_meta('lead') != false) : echo get_meta('lead'); else : the_excerpt(); endif; ?> </p>

<div class="player-download">
<?php if(get_post_meta( get_the_ID(), 'href-link-1080', true )!=null){ ?>
<li><i class="fa fa-download" aria-hidden="true"></i> <a href="<?php echo get_post_meta( get_the_ID(), 'href-link-1080', true ); ?>"> دانلود ویدئو </a><b>DOWNLOAD 1080i </b></li>
<?php } ?>
<?php if(get_post_meta( get_the_ID(), 'href-link-720', true )!=null){ ?>
<li><i class="fa fa-download" aria-hidden="true"></i><a href="<?php echo get_post_meta( get_the_ID(), 'href-link-720', true ); ?>"> دانلود ویدئو </a><b>DOWNLOAD 720i </b></li>
<?php } ?>
<?php if(get_post_meta( get_the_ID(), 'href-link-480', true )!=null){ ?>
<li><i class="fa fa-download" aria-hidden="true"></i><a href="<?php echo get_post_meta( get_the_ID(), 'href-link-480', true ); ?>"> دانلود ویدئو </a><b>DOWNLOAD 480i  </b></li>
<?php } ?>
<?php if(get_post_meta( get_the_ID(), 'href-link-360', true )!=null){ ?>
<li><i class="fa fa-download" aria-hidden="true"></i><a href="<?php echo get_post_meta( get_the_ID(), 'href-link-360', true ); ?>"> دانلود ویدئو </a><b>DOWNLOAD 360i  </b></li>
<?php } ?>
<?php if(get_post_meta( get_the_ID(), 'href-link-240', true )!=null){ ?>
<li><i class="fa fa-download" aria-hidden="true"></i><a href="<?php echo get_post_meta( get_the_ID(), 'href-link-240', true ); ?>">  دانلود ویدئو </a><b>DOWNLOAD 240i  </b></li>
<?php } ?>
</div>

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

<div class="container">
<div class="wrapper">
<div class="ap-page">
<div class="ttit">
<h3><?php the_archive_title(); ?></h3>
</div>
<div class="postlist">
<?php if(have_posts()) : ?> <?php while(have_posts()) : the_post(); ?>
<div class="item">
<div class="thumbnail">
<?php if(has_post_thumbnail()){?>
<a href="<?php the_permalink(); ?>"><img src="<?php the_post_thumbnail_url('loop-2'); ?>" alt="<?php the_title(); ?>"></a>
<?php }else{ ?>
<img src="<?php bloginfo("template_url"); ?>/img/none.png">
<?php } ?>				
 </div>
		 <div class="det">
            <div class="play"><i class="fa fa-play"></i></div>
            <p><?php the_title(); ?></p>
            <time><span><?php the_date('');  ?></b></span></time>
          </div>
           <a class="plink" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"></a> 
        </div>         
<?php endwhile; else: echo "<p>چیزی یافت نشد !</p>"; endif; ?>
 </div>
<?php if (function_exists("pagination")){ pagination($additional_loop->max_num_pages); } ?>
</div>
</div>
</div>
<?php get_footer(); ?>