<!-- Ads Advertisement Start-->
<?php 
global $redux_demo;
$ad_desc = $redux_demo['ad-desc']; 
?>
<section id="advertisementv1" class="sectionBg">
	<div class="row">
		<div class="mainHeading">
			<div class="large-6 medium-8 large-centered medium-centered columns">
				<h4><?php esc_html_e( 'ADVERTISEMENTS', 'classiera' ); ?></h4>
				<p><?php echo $ad_desc; ?></p>
			</div>
		</div><!-- End mainHeading-->
	</div><!-- End Row-->
	<div class="row">
		<div class="advTopBarv1"> 
			<div class="large-5 medium-7 columns medium-centered large-centered data-tab">
				<ul class="tabs" data-tab>
					<li class="tab-title active"><a href="#panel1"><?php esc_html_e( 'Latest Ads', 'classiera' ); ?></a></li>
					<li class="tab-title"><a href="#panel2"><?php esc_html_e( 'Popular Ads', 'classiera' ); ?></a></li>
					<li class="tab-title"><a href="#panel3"><?php esc_html_e( 'Random Ads', 'classiera' ); ?></a></li>
				</ul>
			</div>
		</div><!-- End advTopBarv1-->
	</div><!-- End Row-->
	<div class="row">
		<div class="advContentv1">
			<div class="tabs-content">
				<div class="content active" id="panel1">
				<div class="loop-content">
					<?php 
					global $paged, $wp_query, $wp;
					$args = wp_parse_args($wp->matched_query);
					if ( !empty ( $args['paged'] ) && 0 == $paged ) {
						$wp_query->set('paged', $args['paged']);
						$paged = $args['paged'];
					}
					$ads_counter = $redux_demo['home-ads-counter'];
					$arags = array(
								'post_type' => 'post',
								'posts_per_page' => 8,
								'paged' => $paged
							);
					$wsp_query = new WP_Query($arags);
					$current = -1;
					$current2 = 0;
					?>
					<?php while ($wsp_query->have_posts()) : $wsp_query->the_post(); $current++; $current2++; ?>
					<div class="large-3 medium-6 columns matchHeight end">
						<div class="advItemv1">
							<div class="adv-img">
								<?php 
								if ( has_post_thumbnail()) {
									$imageurl = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'classiera-vsecond');
									$thumb_id = get_post_thumbnail_id($post->id);
									$alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);
									?>
									<div class="home-vsecond">
									<img src="<?php echo $imageurl[0]; ?>" alt="<?php if(empty($alt)){echo "Image";}else{ echo $alt; } ; ?>"/>
									</div>
									<?php										
								}else{
									?>
									<div class="home-vsecond">
									<img src="<?php echo get_template_directory_uri() . '/images/nothumb/nothumb270x180.png' ?>" alt="No Thumb"/>
									</div>
									<?php
								}
								?>
								<span class="img-hover"><a href="<?php the_permalink(); ?>"><?php esc_html_e( 'View', 'classiera' ); ?></a></span>
							</div><!-- End adv-img-->
							<div class="adv-Text">
								<?php 
								$post_price = get_post_meta($post->ID, 'post_price', true); 
								$postCatgory = get_the_category( $post->ID );
								?>
								<?php 
								$theTitle = get_the_title();
								if(is_rtl()){
									$theTitle = get_the_title();
								}else{
									$theTitle = (strlen($theTitle) > 30) ? substr($theTitle,0,30).'...' : $theTitle;
								}
								?>
								<h4><a href="<?php the_permalink(); ?>"><?php echo $theTitle; ?></a></h4>
								<p class="clearfix">
									<span class="cat left"><?php echo $postCatgory[0]->name; ?></span>
									<span class="price right"><?php echo $post_price; ?></span>
								</p>
							</div><!-- End advText-->
						</div><!-- End advItemv1-->
					</div><!-- End large-3 columns end-->
					<?php endwhile; ?>
					<?php wp_reset_postdata(); ?>
				</div><!--loop-content-->
				<?php 
					global $redux_demo;
					$scroll = $redux_demo['infinite-scroll'];
				?>
				<?php if($scroll == 1){ ?>
					<?php echo infinite($wsp_query); ?>
				<?php } ?>
				</div><!-- End panel1-->
				<div class="content" id="panel2">
				<div class="loop-content2">
					<?php 
					global $paged, $wp_query, $wp;
					$args = wp_parse_args($wp->matched_query);
					if ( !empty ( $args['paged'] ) && 0 == $paged ) {
						$wp_query->set('paged', $args['paged']);
						$paged = $args['paged'];
					}
					$current = -1;
					$current2 = 0;
					global $cat_id;
					$popularpost = new WP_Query( array( 'posts_per_page' => 8, 'cat' => $cat_id, 'posts_type' => 'post', 'paged' => $paged, 'meta_key' => 'wpb_post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC'  ) );
					while ( $popularpost->have_posts() ) : $popularpost->the_post(); $current++; $current2++;
					?>
					<div class="large-3 medium-6 columns matchHeight end">
						<div class="advItemv1">
							<div class="adv-img">
								<?php 
								if ( has_post_thumbnail()) {
									$imageurl = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'classiera-vsecond');
									$thumb_id = get_post_thumbnail_id($post->id);
									$alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);
									?>
									<div class="home-vsecond">
									<img src="<?php echo $imageurl[0]; ?>" alt="<?php if(empty($alt)){echo "Image";}else{ echo $alt; } ; ?>"/>
									</div>
									<?php										
								}else{
									?>
									<div class="home-vsecond">
									<img src="<?php echo get_template_directory_uri() . '/images/nothumb/nothumb270x180.png' ?>" alt="No Thumb"/>
									</div>
									<?php
								}
								?>
								<span class="img-hover"><a href="<?php the_permalink(); ?>"><?php esc_html_e( 'View', 'classiera' ); ?></a></span>
							</div><!-- End adv-img-->
							<div class="adv-Text">
								<?php 
								$post_price = get_post_meta($post->ID, 'post_price', true); 
								$postCatgory = get_the_category( $post->ID );
								?>
								<?php 
								$theTitle = get_the_title();
								if(is_rtl()){
									$theTitle = get_the_title();
								}else{
									$theTitle = (strlen($theTitle) > 30) ? substr($theTitle,0,30).'...' : $theTitle;
								}
								?>
								<h4><a href="<?php the_permalink(); ?>"><?php echo $theTitle; ?></a></h4>
								<p class="clearfix">
									<span class="cat left"><?php echo $postCatgory[0]->name; ?></span>
									<span class="price right"><?php echo $post_price; ?></span>
								</p>
							</div><!-- End advText-->
						</div><!-- End advItemv1-->
					</div><!--large-3 columns end-->
					<?php endwhile; ?>
					<?php wp_reset_postdata(); ?>
				</div><!--loop-content2-->
				<?php 
					global $redux_demo;
					$scroll = $redux_demo['infinite-scroll'];
				?>
				<?php if($scroll == 1){ ?>
					<?php echo infinite($popularpost); ?>
				<?php } ?>
				</div><!-- End panel2-->
				<div class="content" id="panel3">
				<div class="loop-content3">
					<?php 
					global $paged, $wp_query, $wp;
					$args = wp_parse_args($wp->matched_query);
					if ( !empty ( $args['paged'] ) && 0 == $paged ) {
						$wp_query->set('paged', $args['paged']);
						$paged = $args['paged'];
					}
					$argas = array(
								'orderby' => 'title',
								'post_type' => 'post',
								'posts_per_page' => 8,
								'paged' => $paged
							);
					$wdp_query = new WP_Query($argas);
					$current = -1;
					$current2 = 0;
					?>
					<?php while ($wdp_query->have_posts()) : $wdp_query->the_post(); $current++; $current2++; ?>
					<div class="large-3 medium-6 columns matchHeight end">
						<div class="advItemv1">
							<div class="adv-img">
								<?php 
								if ( has_post_thumbnail()) {
									$imageurl = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'classiera-vsecond');
									$thumb_id = get_post_thumbnail_id($post->id);
									$alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);
									?>
									<div class="home-vsecond">
									<img src="<?php echo $imageurl[0]; ?>" alt="<?php if(empty($alt)){echo "Image";}else{ echo $alt; } ; ?>"/>
									</div>
									<?php										
								}else{
									?>
									<div class="home-vsecond">
									<img src="<?php echo get_template_directory_uri() . '/images/nothumb/nothumb270x180.png' ?>" alt="No Thumb"/>
									</div>
									<?php
								}
								?>
								<span class="img-hover"><a href="<?php the_permalink(); ?>"><?php esc_html_e( 'View', 'classiera' ); ?></a></span>
							</div><!-- End adv-img-->
							<div class="adv-Text">
								<?php 
								$post_price = get_post_meta($post->ID, 'post_price', true); 
								$postCatgory = get_the_category( $post->ID );
								?>
								<?php 
								$theTitle = get_the_title();
								if(is_rtl()){
									$theTitle = get_the_title();
								}else{
									$theTitle = (strlen($theTitle) > 30) ? substr($theTitle,0,30).'...' : $theTitle;
								}
								?>
								<h4><a href="<?php the_permalink(); ?>"><?php echo $theTitle; ?></a></h4>
								<p class="clearfix">
									<span class="cat left"><?php echo $postCatgory[0]->name; ?></span>
									<span class="price right"><?php echo $post_price; ?></span>
								</p>
							</div><!-- End advText-->
						</div><!-- End advItemv1-->
					</div><!-- End large-3 columns end-->
					<?php endwhile; ?>
					<?php wp_reset_postdata(); ?>
				</div><!--loop-content-->	
				<?php 
					global $redux_demo;
					$scroll = $redux_demo['infinite-scroll'];
				?>
				<?php if($scroll == 1){ ?>
					<?php echo infinite($wdp_query); ?>
				<?php } ?>
				</div><!-- End panel3-->
			</div><!-- End tabs-content-->
		</div><!-- End advContentv1-->
	</div><!-- End Row-->
	<?php $scroll = $redux_demo['infinite-scroll'];?>
	<?php if($scroll != 1){	?>
		<div class="row">
		<?php 
		$viewAllAds = $redux_demo['all-ads-page-link']; 
		$trnsViewAll = $redux_demo['trns-btn-viewall'];
		?>
			<div class="view-all text-center">
				<a href="<?php echo $viewAllAds; ?>" class="button radius"><?php echo $trnsViewAll; ?></a>
			</div>
		</div><!-- End Row for View All Ads Button-->
	<?php }?>	
</section>	
<!-- Ads Advertisement End-->