		<?php 
			global $current_view_type;
			global $permalink_type;
			global $redux_demo;
			$ad_desc = $redux_demo['ad-desc'];
			$view = $redux_demo['home-ads-view'];
			$category_icon_code = "";
			$category_icon_color = "";
			$your_image_url = "";
			$category_icon="";
			$caticoncolor="";
			global $wp_rewrite;
			global $redux_demo;
			if ($wp_rewrite->permalink_structure == ''){
				//we are using ?page_id
				$permalink_type = "&";
			}else{
				//we are using permalinks
				$permalink_type = "?";
			}
			if (is_page_template( 'template-homepage-v1.php' )){
				//we are using ?page_id
				$permalink_type = "?";
			}
		?>
<!-- Advertisement Section Start -->
<section id="advertisement">
	<div class="row">
		<div class="mainHeading">
			<div class="large-7 medium-8 large-centered medium-centered columns">
				<h2><?php esc_html_e( 'ADVERTISEMENTS', 'classiera' ); ?></h2>
				<p><span class="line"><i class="fa fa-circle"></i></span></p>
				<?php if(!empty($ad_desc)){ ?>
				<p><?php echo $ad_desc; ?></p>
				<?php } ?>
			</div>
		</div>
	</div><!-- END Heading Row-->
	<div class="row">
		<div class="advTopBar">
			<div class="large-6 medium-6 columns tabb tabs data-tab responsive-tabber">
				<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><!-- END tabber Div-->
			<div class="large-6 medium-6 columns view tabs data-tab responsive-tabber">
				<span><?php esc_html_e( 'View As', 'classiera' ); ?></span>
				<a class="act1 <?php if($current_view_type == 'list'){ echo "active";} ?>" href="<?php echo get_permalink().$permalink_type."view-type=list"; ?>"><i class="fa fa-list"></i></a>
				<a class="act3 <?php if($current_view_type == 'grid'){ echo "active";} ?>" href="<?php echo get_permalink().$permalink_type."view-type=grid"; ?>"><i class="fa fa-th"></i></a>
			</div><!-- END View Button-->
		</div>
	</div><!-- END Right Button Row-->
	<div class="row">
		<div class="advContent"> 
			<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' => $ads_counter,
								'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-4 medium-6 columns advItems matchHeight end">
						<div class="advItem"> 
							<?php 
							if ( has_post_thumbnail()) {
								$imageurl = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'classiera-grid');
								$thumb_id = get_post_thumbnail_id($post->id);
								$alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);
								?>
								<div class="advItem-img">
									<img src="<?php echo $imageurl[0]; ?>" alt="<?php if(empty($alt)){echo "Image";}else{ echo $alt; } ; ?>"/>
								</div>
								<?php										
							}else{
								?>
								<div class="advItem-img">
									<img src="<?php echo get_template_directory_uri() . '/images/nothumb/nothumb370x300.png' ?>" alt="No Thumb"/>
								</div>
								<?php
							}
								/*Get Category Extra Fields For Price Icon Background */
								$category = get_the_category();
									if ($category[0]->category_parent == 0) {
										$tag = $category[0]->cat_ID;
										$tag_extra_fields = get_option(MY_CATEGORY_FIELDS);
										if (isset($tag_extra_fields[$tag])) {
											$category_icon_code = $tag_extra_fields[$tag]['category_icon_code'];
											$category_icon_color = $tag_extra_fields[$tag]['category_icon_color'];
										}
									}else{
										$tag = $category[0]->category_parent;
										$tag_extra_fields = get_option(MY_CATEGORY_FIELDS);
										if (isset($tag_extra_fields[$tag])) {
											$category_icon_code = $tag_extra_fields[$tag]['category_icon_code'];
											$category_icon_color = $tag_extra_fields[$tag]['category_icon_color'];
										}
									}
									if(!empty($category_icon_code)) {
										$category_icon = stripslashes($category_icon_code);
									}
									$category_icon_code = "";
								/*Get Category Extra Fields For Price Icon Background */
							$post_price = get_post_meta($post->ID, 'post_price', true);
							if(!empty($post_price)){
							?>
							<span class="price" style="background-color:<?php echo $category_icon_color; ?>"><?php echo $post_price; ?></span>
							<?php }?>
							<a class="hover" href="<?php the_permalink(); ?>"></a>
							<div class="info">
								<a href="<?php the_permalink(); ?>">
								<?php 
									$postCatgory = get_the_category( $post->ID );
									//echo $postCatgory[0]->name;
								?>
									<i class="<?php echo $category_icon; ?>" style="background-color:<?php echo $category_icon_color; ?>"></i>
									<?php 
									$theTitle = get_the_title();
									if(is_rtl()){
										$theTitle = get_the_title();
									}else{
										$theTitle = (strlen($theTitle) > 30) ? substr($theTitle,0,30).'...' : $theTitle;
									}
									?>
									<span class="title"><?php echo $theTitle; ?></span>
									<span class="cat"><?php esc_html_e( 'Category', 'classiera' ); ?> &nbsp;:&nbsp;<?php echo $postCatgory[0]->name; ?></span>
								</a>
							</div>
						</div>
					</div>
					<?php endwhile; ?>
					<?php wp_reset_postdata(); ?>
				</div>
				<?php 
					global $redux_demo;
					$scroll = $redux_demo['infinite-scroll'];
				?>
				<?php if($scroll == 1){ ?>
					<?php echo infinite($wsp_query); ?>
				<?php } ?>				
				</div>
				<?php //echo infinite($wsp_query); ?>	
				<!-- End Latest Ads -->
				<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-4 medium-6 columns advItems matchHeight end">
						<div class="advItem">
							<?php 
							if ( has_post_thumbnail()) {
								$imageurl = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'classiera-grid');
								$thumb_id = get_post_thumbnail_id($post->id);
								$alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);
								?>
								<div class="advItem-img">
									<img src="<?php echo $imageurl[0]; ?>" alt="<?php if(empty($alt)){echo "Image";}else{ echo $alt; } ; ?>"/>
								</div>
								<?php										
							}else{
								?>
								<div class="advItem-img">
									<img src="<?php echo get_template_directory_uri() . '/images/nothumb/nothumb370x300.png' ?>" alt="No Thumb"/>
								</div>
								<?php
							}
								/*Get Category Extra Fields For Price Icon Background */
								$category = get_the_category();
									if ($category[0]->category_parent == 0) {
										$tag = $category[0]->cat_ID;
										$tag_extra_fields = get_option(MY_CATEGORY_FIELDS);
										if (isset($tag_extra_fields[$tag])) {
											$category_icon_code = $tag_extra_fields[$tag]['category_icon_code'];
											$category_icon_color = $tag_extra_fields[$tag]['category_icon_color'];
										}
									}else{
										$tag = $category[0]->category_parent;
										$tag_extra_fields = get_option(MY_CATEGORY_FIELDS);
										if (isset($tag_extra_fields[$tag])) {
											$category_icon_code = $tag_extra_fields[$tag]['category_icon_code'];
											$category_icon_color = $tag_extra_fields[$tag]['category_icon_color'];
										}
									}
									if(!empty($category_icon_code)) {
										$category_icon = stripslashes($category_icon_code);
									}
									$category_icon_code = "";
								/*Get Category Extra Fields For Price Icon Background */
								$post_price = get_post_meta($post->ID, 'post_price', true);
							if(!empty($post_price)){
							?>
							<span class="price" style="background-color:<?php echo $category_icon_color; ?>"><?php echo $post_price; ?></span>
							<?php }?>
							<a class="hover" href="<?php the_permalink(); ?>"></a>
							<div class="info">
								<a href="<?php the_permalink(); ?>">
								<?php 
									$postCatgory = get_the_category( $post->ID );
									//print_r($postCatgory);
									//echo $postCatgory[0]->name;
								?>
									<i class="<?php echo $category_icon; ?>" style="background-color:<?php echo $category_icon_color; ?>"></i>
									<?php 
									$theTitle = get_the_title();
									if(is_rtl()){
										$theTitle = get_the_title();
									}else{
										$theTitle = (strlen($theTitle) > 30) ? substr($theTitle,0,30).'...' : $theTitle;
									}
									?>
									<span class="title"><?php echo $theTitle; ?></span>
									<span class="cat"><?php esc_html_e( 'Category', 'classiera' ); ?> &nbsp;:&nbsp;<?php echo $postCatgory[0]->name; ?></span>
								</a>
							</div>
						</div>
					</div><!-- End box HTML -->
					<?php endwhile; ?>
					<?php wp_reset_postdata(); ?>
				<?php //echo infinite($popularpost); ?>
				</div>
				<?php 
					global $redux_demo;
					$scroll = $redux_demo['infinite-scroll'];
				?>
				<?php if($scroll == 1){ ?>
					<?php echo infinite($popularpost); ?>
				<?php } ?>
				</div>
				
				<!-- End Popular Ads -->
				<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-4 medium-6 columns advItems matchHeight end">
						<div class="advItem">
							<?php 
							if ( has_post_thumbnail()) {
								$imageurl = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'classiera-grid');
								$thumb_id = get_post_thumbnail_id($post->id);
								$alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);
								?>
								<div class="advItem-img">
									<img src="<?php echo $imageurl[0]; ?>" alt="<?php if(empty($alt)){echo "Image";}else{ echo $alt; } ; ?>"/>
								</div>
								<?php										
							}else{
								?>
								<div class="advItem-img">
									<img src="<?php echo get_template_directory_uri() . '/images/nothumb/nothumb370x300.png' ?>" alt="No Thumb"/>
								</div>
								<?php
							}
								
								/*Get Category Extra Fields For Price Icon Background */
								$category = get_the_category();
									if ($category[0]->category_parent == 0) {
										$tag = $category[0]->cat_ID;
										$tag_extra_fields = get_option(MY_CATEGORY_FIELDS);
										if (isset($tag_extra_fields[$tag])) {
											$category_icon_code = $tag_extra_fields[$tag]['category_icon_code'];
											$category_icon_color = $tag_extra_fields[$tag]['category_icon_color'];
										}
									}else{
										$tag = $category[0]->category_parent;
										$tag_extra_fields = get_option(MY_CATEGORY_FIELDS);
										if (isset($tag_extra_fields[$tag])) {
											$category_icon_code = $tag_extra_fields[$tag]['category_icon_code'];
											$category_icon_color = $tag_extra_fields[$tag]['category_icon_color'];
										}
									}
									if(!empty($category_icon_code)) {
										$category_icon = stripslashes($category_icon_code);
									}
									$category_icon_code = "";
								/*Get Category Extra Fields For Price Icon Background */
								$post_price = get_post_meta($post->ID, 'post_price', true);
								if(!empty($post_price)){
							?>
							<span class="price" style="background-color:<?php echo $category_icon_color; ?>"><?php echo $post_price; ?></span>
							<?php }?>
							<a class="hover" href="<?php the_permalink(); ?>"></a>
							<div class="info">
								<a href="<?php the_permalink(); ?>">
								<?php 
									$postCatgory = get_the_category( $post->ID );
									//print_r($postCatgory);
									//echo $postCatgory[0]->name;
								?>
									<i class="<?php echo $category_icon; ?>" style="background-color:<?php echo $category_icon_color; ?>"></i>
									<?php 
									$theTitle = get_the_title();
									if(is_rtl()){
										$theTitle = get_the_title();
									}else{
										$theTitle = (strlen($theTitle) > 30) ? substr($theTitle,0,30).'...' : $theTitle;
									}
									?>
									<span class="title"><?php echo $theTitle; ?></span>
									<span class="cat"><?php esc_html_e( 'Category', 'classiera' ); ?> &nbsp;:&nbsp;<?php echo $postCatgory[0]->name; ?></span>
								</a>
							</div>
							
						</div>
					</div> <!--End Box --> 
					<?php endwhile; ?>
					<?php wp_reset_postdata(); ?>
				</div>
				<?php 
					global $redux_demo;
					$scroll = $redux_demo['infinite-scroll'];
				?>
				<?php if($scroll == 1){ ?>
					<?php echo infinite($wdp_query); ?>
				<?php } ?>
				</div>				
				<!-- End Random Ads -->
			</div>
		</div>
	</div><!-- END Main Ads Section-->
	<?php $scroll = $redux_demo['infinite-scroll'];
	if($scroll != 1){
	?>
	<div class="row">
	<?php 
	$viewAllAds = $redux_demo['all-ads-page-link']; 
	$trnsViewAll = $redux_demo['trns-btn-viewall'];
	?>		
		<div class="loadMore">
			<p>
				<a href="<?php echo $viewAllAds; ?>">
					<i class="fa fa-refresh"></i><?php echo $trnsViewAll; ?>
				</a>
			</p>
		</div>
			
	</div><!-- End Row for View All Ads Button-->
	<?php }?>
</section>
<!-- END Advertisement Section-->