<?php
/**
 * The template for displaying Category pages.
 *
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Classiera
 * @since Classiera 1.0
 */

get_header(); ?>

	<?php 

		// Retrieve the URL variables (using PHP).
		global $redux_demo;
		$locShownBy = $redux_demo['location-shown-by'];
		$keyword = $_GET['s'];
		$post_location_search ="All";
		if(isset($_GET['post_location'])){
			$post_location_search = $_GET['post_location'];
		}
		$category_name ="";
		if(isset($_GET['category_name'])){
			$category_name = $_GET['category_name'];
		}
		$geo_location = "";
		if(isset($_GET['geo-location'])){
			$geo_location = $_GET['geo-location'];
		}
		
		if(isset($_GET['geo-radius-search'])){
			$geo_radius_search = $_GET['geo-radius-search'];
		}
		
		if(isset($_GET['geo-search-lat'])){
			$geo_search_lat = $_GET['geo-search-lat'];
		}
		
		if(isset($_GET['geo-search-lng'])){
			$geo_search_lng = $_GET['geo-search-lng'];
		}
		$category_icon_code = "";
		$category_icon ="";
		$category_icon_color = "";
		$your_image_url = "";
		$caticoncolor="";
		$emptyPost="";
		$catSearchID ="";
		if(isset($_GET['category_name'])){
			if($category_name != "All") {			
				$thisCat = get_category(get_query_var('cat'),false);
					if(isset($thisCat)){
						$catSearchID = $thisCat->term_id;
					}
					
			} else {
				$catSearchID = '-1';
			}
		}

		
/* My Title Code*/
$MyKeyword ="";
$MyCat ="";
$myLoc ="";
if($keyword == "") {	
	$MyKeyword =  esc_html__( 'All Post', 'classiera' );
}
if($category_name == "All") {	
	$MyCat =  esc_html__( 'All Categories', 'classiera' );
}
if($post_location_search == "All"){	
	$myLoc =  esc_html__( 'All Locations', 'classiera' );
}
/* My Title Code*/
if($keyword == "all") {
			$keyword = '';
		} else {
			$keyword = $keyword;
		}

	global $redux_demo, $maximRange; 
	$max_range = $redux_demo['max_range'];
	if(!empty($max_range)) {
		$maximRange = $max_range;
	} else {
		$maximRange = 1000;
	}

	?>
<?php $titleBg = $redux_demo['title-bg']['url']; ?>	
<section class="pageHeading" style="background:url(<?php echo $titleBg; ?>);">
    <div class="row">
        <h3><?php printf( __( 'You have search: ', 'classiera' )); ?>		
		<?php 
			if(empty($keyword)){
				echo $MyKeyword;
			}else{
				echo $keyword;
			}			
		?>
		<?php printf( __( 'From ', 'classiera' )); ?>
		<?php 
			if($category_name == "All"){
				echo $MyCat;
			}else{
				echo $category_name;
			}			
		?>
		</h3> 
		<p>
			<i class="fa fa-map-marker"></i>
			<?php printf( __( 'Location: ', 'classiera' )); ?>
			<?php 
			if($post_location_search == "All"){
				echo $myLoc;
			}else{
				echo $post_location_search;
			}			
			?>
		</p>
    </div>
</section><!-- End page Heading -->	
<?php 
	global $redux_demo; 
	$featured_ads_option = $redux_demo['featured-options-on'];
	$premiumSECtitle = $redux_demo['premium-sec-title'];
	$premiumSECdesc = $redux_demo['premium-sec-desc'];
?>
<?php if($featured_ads_option == 1) { ?>
<!-- Premium Advertisement Start -->
	<section id="premiumAdv">
		<div class="row">
			<div class="mainHeading">
				<div class="large-7 medium-8 large-centered medium-centered columns">
					<h2><?php echo $premiumSECtitle;?></h2>
					<p><span class="line"><i class="fa fa-circle"></i></span></p>
					<p><?php echo $premiumSECdesc;?></p>
				</div>
			</div><!--End mainHeading-->
		</div><!--End Heading row-->
		<div class="customNavigation">
			<div class="row">
				<div class="medium-4 medium-centered columns">
				<?php 
					$previous = $redux_demo['trns-btn-previous'];
					$next = $redux_demo['trns-btn-next'];
					$caraCategory = $redux_demo['trns-cara-cat'];
				?>
					<div class="navText">
                        <a class="prev"><i class="fa fa-angle-left"></i></a>
                        <span><?php echo $previous;?></span>
                        <span><?php echo $next;?></span>
                        <a class="next"><i class="fa fa-angle-right"></i></a>
                    </div>
				</div>
			</div>
		</div><!--End customNavigation-->
		<!--Start Premium Carousel-->
		<?php $cat_id = get_cat_ID(single_cat_title('', false)); ?>
		<div id="owl-demo" class="owl-carousel">
			<?php global $paged, $wp_query, $wp, $current, $current2; 
			$args = wp_parse_args($wp->matched_query);
			$temp = $wp_query;
			$wp_query= null;
			$wp_query = new WP_Query();
			$wp_query->query('post_type=post&s='.$keyword.'&posts_per_page=-1&cat='.$catSearchID);
			$featuredCurrent = 0;
			while ($wp_query->have_posts()) : $wp_query->the_post(); 
			$featured_post = get_post_meta($post->ID, 'featured_post', true);
			?>
			<?php if($featured_post == "1") { $current++; $current2++; $featuredCurrent++; ?>
				<?php if($geo_location == 'on') { ?>
					<?php if($post_location_search == 'All') {?>
						<?php 
							$emptyPost++;
							$post_latitude = get_post_meta($post->ID, 'post_latitude', true);
							$post_longitude = get_post_meta($post->ID, 'post_longitude', true);
							if(!empty($post_latitude)) { 
								global $redux_demo;
								$measure_system = $redux_demo['measure-system'];
								if(!empty($measure_system)) {
									if($measure_system == "1") { 
										$distance = 3958.755864232 * acos(sin($post_latitude / 57.2958) * sin($geo_search_lat / 57.2958) +cos($post_latitude / 57.2958) * cos($geo_search_lat / 57.2958) *cos($geo_search_lng / 57.2958 - $post_longitude / 57.2958));
									}else{
										$distance = 6371 * acos(sin($post_latitude / 57.2958) * sin($geo_search_lat / 57.2958) +cos($post_latitude / 57.2958) * cos($geo_search_lat / 57.2958) *cos($geo_search_lng / 57.2958 - $post_longitude / 57.2958));
									}
								}else{/* End if measure_system */
									$distance = 6371 * acos(sin($post_latitude / 57.2958) * sin($geo_search_lat / 57.2958) +cos($post_latitude / 57.2958) * cos($geo_search_lat / 57.2958) *cos($geo_search_lng / 57.2958 - $post_longitude / 57.2958));
								}
								if( $distance <= $geo_radius_search ) {
									?>
									<div class="item">
										<div class="carousel">
										<?php 
											if ( has_post_thumbnail()) {
												$premiumAimage = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
												$thumbImg = get_the_post_thumbnail($post->ID, '270x220');
												//print_r($premiumAimage);
												$postTiti= get_the_title();
												echo $thumbImg;
											}else{
												?>
												<img src="<?php echo get_template_directory_uri() . '/images/nothumb/nothumb270x250.png' ?>" alt="No Thumb"/>
												<?php
											}					
										?>													
										<?php
											$post_price = get_post_meta($post->ID, 'post_price', true);
											if(!empty($post_price)){								
											?>
												<span class="price"><?php echo $post_price; ?></span>
											<?php } ?>
											<div class="hover">
												<?php 
													$category = get_the_category();
													if ($category[0]->category_parent == 0) {
														$tag = $category[0]->cat_ID;
														$category_icon_code = "";
														$category_icon_color = "";
														$your_image_url = "";
														$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)) {
														$catIcon = stripslashes($category_icon_code);
													}
													$category_icon_code = "";
													$postCatgory = get_the_category( $post->ID );
												?>
												<a href="<?php the_permalink(); ?>">						
													<span class="info">
														<i class="<?php echo $catIcon; ?>" style="background-color:<?php echo $category_icon_color; ?>"></i>
														<span class="title"><?php echo $postTiti; ?></span>
														<small><?php echo $caraCategory; ?> :
														<?php echo $postCatgory[0]->name; ?></small>
													</span>
												</a>
											</div>
										</div>
										
									</div>
									<?php
									
								}/* End if distance */
							
							}/* End if post_latitude */
						?>
					<?php }else{ /* End if post_location_search */
							$post_location = get_post_meta($post->ID, $locShownBy, true); 
								if($post_location == $post_location_search) {
									$emptyPost++;
									$post_latitude = get_post_meta($post->ID, 'post_latitude', true);
									$post_longitude = get_post_meta($post->ID, 'post_longitude', true);
									if(!empty($post_latitude)) { 
										global $redux_demo;
										$measure_system = $redux_demo['measure-system'];
										if(!empty($measure_system)) {
											if($measure_system == "1") { 
												$distance = 3958.755864232 * acos(sin($post_latitude / 57.2958) * sin($geo_search_lat / 57.2958) +cos($post_latitude / 57.2958) * cos($geo_search_lat / 57.2958) *cos($geo_search_lng / 57.2958 - $post_longitude / 57.2958));
											}else{
												$distance = 6371 * acos(sin($post_latitude / 57.2958) * sin($geo_search_lat / 57.2958) +cos($post_latitude / 57.2958) * cos($geo_search_lat / 57.2958) *cos($geo_search_lng / 57.2958 - $post_longitude / 57.2958));
											}
										}else{/* End if !empty($measure_system*/
											$distance = 6371 * acos(sin($post_latitude / 57.2958) * sin($geo_search_lat / 57.2958) +cos($post_latitude / 57.2958) * cos($geo_search_lat / 57.2958) *cos($geo_search_lng / 57.2958 - $post_longitude / 57.2958));
										}
										if( $distance <= $geo_radius_search ) {
											?>
											<div class="item">
												<div class="carousel">
												<?php 
													if ( has_post_thumbnail()) {
														$premiumAimage = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
														$thumbImg = get_the_post_thumbnail($post->ID, '270x220');
														//print_r($premiumAimage);
														$postTiti= get_the_title();
														echo $thumbImg;
													}else{
														?>
														<img src="<?php echo get_template_directory_uri() . '/images/nothumb/nothumb270x250.png' ?>" alt="No Thumb"/>
														<?php
													}					
												?>
																
												<?php
													$post_price = get_post_meta($post->ID, 'post_price', true);
													if(!empty($post_price)){								
													?>
														<span class="price"><?php echo $post_price; ?></span>
													<?php } ?>
													<div class="hover">
														<?php 
															$category_icon_code = "";
															$category_icon_color = "";
															$your_image_url = "";
															$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)) {
																$catIcon = stripslashes($category_icon_code);
															}
															$category_icon_code = "";
															$postCatgory = get_the_category( $post->ID );
														?>
														<a href="<?php the_permalink(); ?>">						
															<span class="info">
																<i class="<?php echo $catIcon; ?>" style="background-color:<?php echo $category_icon_color; ?>"></i>
																<span class="title"><?php echo $postTiti; ?></span>
																<small><?php echo $caraCategory; ?> :
																<?php echo $postCatgory[0]->name; ?></small>
															</span>
														</a>
													</div>
												</div>
												
											</div>
											<?php
										}/* End if $distance <= $geo_radius_search*/
									}/* End if !empty($post_latitude*/
								}/* End if $post_location == $post_location_search */
							}
					?>
				<?php }else{ /* End if geo_location */
							$emptyPost="";
							if($post_location_search == 'All') {
								$emptyPost++;
								?>
								<div class="item">
									<div class="carousel">
									<?php 
										if ( has_post_thumbnail()) {
										$imageurl = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'classiera-pslider');
										$thumb_id = get_post_thumbnail_id($post->id);
										$alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);			
										$postTiti= get_the_title();
										?>
										<div class="premiumIMG"><img src="<?php echo $imageurl[0]; ?>" alt="<?php if(empty($alt)){echo "Image";}else{ echo $alt; } ; ?>"/></div>
										<?php
									}else{
										?>
										<div class="premiumIMG">
												<img src="<?php echo get_template_directory_uri() . '/images/nothumb/nothumb270x250.png' ?>" alt="No Thumb"/>
											</div>
										<?php
									}					
									?>
													
									<?php
										$post_price = get_post_meta($post->ID, 'post_price', true);
										if(!empty($post_price)){								
										?>
											<span class="price"><?php echo $post_price; ?></span>
										<?php } ?>
										<div class="hover">
											<?php 
												$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)) {
													$catIcon = stripslashes($category_icon_code);
												}
												$category_icon_code = "";
												$postCatgory = get_the_category( $post->ID );
											?>
											<a href="<?php the_permalink(); ?>">						
												<span class="info">
													<i class="<?php echo $catIcon; ?>" style="background-color:<?php echo $category_icon_color; ?>"></i>
													<span class="title"><?php echo $postTiti; ?></span>
													<small><?php echo $caraCategory; ?> :
													<?php echo $postCatgory[0]->name; ?></small>
												</span>
											</a>
										</div>
									</div>
									
								</div>
								<?php 
							}else{ /* post_location_search */
								$post_location = get_post_meta($post->ID, $locShownBy, true);
								if($post_location == $post_location_search) {
									$emptyPost++;
									?>
									<div class="item">
										<div class="carousel">
										<?php 
											if ( has_post_thumbnail()) {
												$premiumAimage = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
												$thumbImg = get_the_post_thumbnail($post->ID, '270x220');
												//print_r($premiumAimage);
												$postTiti= get_the_title();
												echo $thumbImg;
											}else{
												?>
												<img src="<?php echo get_template_directory_uri() . '/images/nothumb/nothumb270x250.png' ?>" alt="No Thumb"/>
												<?php
											}					
										?>
													
										<?php
											$post_price = get_post_meta($post->ID, 'post_price', true);
											if(!empty($post_price)){								
											?>
												<span class="price"><?php echo $post_price; ?></span>
											<?php } ?>
											<div class="hover">
												<?php 
													$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)) {
														$catIcon = stripslashes($category_icon_code);
													}
													$category_icon_code = "";
													$postCatgory = get_the_category( $post->ID );
												?>
												<a href="<?php the_permalink(); ?>">						
													<span class="info">
														<i class="<?php echo $catIcon; ?>" style="background-color:<?php echo $category_icon_color; ?>"></i>
														<span class="title"><?php echo $postTiti; ?></span>
														<small><?php echo $caraCategory; ?> :
														<?php echo $postCatgory[0]->name; ?></small>
													</span>
												</a>
											</div>
										</div>
										
									</div>
									<?php
								}/* post_location == $post_location_search */
							}
						}
				?>
			<?php } ?>
			<?php endwhile; ?>
			<?php wp_reset_query(); ?>
		</div>
		<?php if($emptyPost == 0) { ?>
		<div class="row">
			<div class="large-7 medium-8 large-centered medium-centered columns">
				<p class="text-center"><?php esc_html_e( 'No results found in Premium Section for the selected search criteria.', 'classiera' ); ?></p>
			</div>
		</div>
		<?php } ?>
		<!--End Premium Carousel-->
		
	</section><!-- End premiumAdv-->
<!-- Premium Advertisement End-->
<?php }?>
<!-- Main Ads section Start -->
<!-- Main Ads section Start -->
<?php 
global $current_view_type;
global $permalink_type;
global $redux_demo;
$ad_desc = $redux_demo['ad-desc'];
?>
<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( 'Relevant Ads', '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="tabs-content listView">
			<div class="content active" id="panel1">
				<?php 
				global $paged, $wp_query, $wp;
				$args = wp_parse_args($wp->matched_query);
				$temp = $wp_query;
				$wp_query= null;
				$wp_query = new WP_Query();
				$wp_query->query('post_type=post&s='.$keyword.'&posts_per_page=-1&cat='.$catSearchID);
				//print_r($wp_query);exit();
				$current = -1;
				$current2 = 0;
				$emptyPost2 = 0;
				?>
				<?php while ($wp_query->have_posts()) : $wp_query->the_post();
					if($geo_location == 'on') {
						if($post_location_search == 'All') {
							$current++; $current2++; $emptyPost2++;
							$post_latitude = get_post_meta($post->ID, 'post_latitude', true);
							$post_longitude = get_post_meta($post->ID, 'post_longitude', true);
							if(!empty($post_latitude)) { 
								global $redux_demo;
								$measure_system = $redux_demo['measure-system'];
								if(!empty($measure_system)) {
									if($measure_system == "1") { 
										$distance = 3958.755864232 * acos(sin($post_latitude / 57.2958) * sin($geo_search_lat / 57.2958) +cos($post_latitude / 57.2958) * cos($geo_search_lat / 57.2958) *cos($geo_search_lng / 57.2958 - $post_longitude / 57.2958));
									}else{
										$distance = 6371 * acos(sin($post_latitude / 57.2958) * sin($geo_search_lat / 57.2958) +cos($post_latitude / 57.2958) * cos($geo_search_lat / 57.2958) *cos($geo_search_lng / 57.2958 - $post_longitude / 57.2958));
									}
								}else{ /*End If $measure_system */
									$distance = 6371 * acos(sin($post_latitude / 57.2958) * sin($geo_search_lat / 57.2958) +cos($post_latitude / 57.2958) * cos($geo_search_lat / 57.2958) *cos($geo_search_lng / 57.2958 - $post_longitude / 57.2958));
								}
								if( $distance <= $geo_radius_search ) {
									?>
									<div class="large-12 medium-12 columns advItems end">
									<?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 = "";
											$postCatgory = get_the_category( $post->ID );
											$post_price = get_post_meta($post->ID, 'post_price', true);
											$comments_count = wp_count_comments( $post->ID  );
											$approvedComment = $comments_count->approved;
									/*Get Category Extra Fields For Price Icon Background */
									?>
									<article class="listAdv">
										<div class="row">
											<div class="large-3 medium-4 column">
												<div class="list-img">
													<?php if(!empty($post_price)){ ?>
													<span class="listPrice" style="background-color:<?php echo $category_icon_color; ?>"><?php echo $post_price; ?></span>
													<?php }?>
													<?php /*Start Image */
													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() . '/images/nothumb/nothumb370x300.png' ?>" alt="No Thumb"/>
														</div>
														<?php
													}
												/*End Image */?>
													<div class="listcomment">
														<span><?php echo $approvedComment; ?></span>
														<i class="fa fa-comments"></i>
														<span><?php echo classiera_get_post_views($post->ID); ?></span>
														<i class="fa fa-eye"></i>
													</div>	<!-- End listcomment-->
												</div>
											</div><!-- End large-3 medium-4 column-->
											<div class="large-9 medium-8 column">
												<div class="listAdv-desc">
													<div class="row">
														<div class="large-6 medium-7 columns">
															<div class="listAdv-desc-header">
																<div class="icon">
																	<i class="<?php echo $category_icon; ?>" style="background-color:<?php echo $category_icon_color; ?>"></i>
																	<h4><a href="<?php the_permalink(); ?>"><?php $theTitle = get_the_title(); $theTitle = (strlen($theTitle) > 25) ? substr($theTitle,0,25).'...' : $theTitle; echo $theTitle; ?></a></h4>
																	<span><?php esc_html_e( 'Category', 'classiera' ); ?> &nbsp;:&nbsp;<?php echo $postCatgory[0]->name; ?></span>
																</div>
															</div>
														</div><!-- large-9-->
														<div class="large-6 medium-5 column">
														<?php if(function_exists('the_ratings')) { ?>
															<div class="rating">
																<?php the_ratings(); ?>
															</div>
														<?php } ?>	
														</div><!-- large-3-->
													</div><!-- listAdv First Row-->
													<div class="row">
														<div class="large-12 columns">
															<div class="listAdv-desc-detail">
																<?php echo substr(get_the_excerpt(), 0,260); ?>
															</div>
														</div>
													</div><!-- listAdv second Row-->
													<div class="row">
														<div class="listAdv-tags">
															<div class="large-6 medium-7 columns">
																<div class="listTags">
																	<i class="fa fa-tags"></i>
																	<span><?php esc_html_e('Tags', 'classiera'); ?>:</span>
																	<?php the_tags('','',''); ?>
																</div><!-- listTags-->
															</div><!-- large-6-->
															<div class="large-6 medium-5 columns">
																<div class="listReadMore">
																	<a href="<?php the_permalink(); ?>">
																	<?php esc_html_e( 'Read More', 'classiera' ); ?>
																	</a>
																</div>
															</div><!-- large-6 medium-5-->
														</div><!-- listAdv-tags-->
													</div><!-- listAdv third Row-->
												</div><!-- listAdv-desc-->
											</div><!-- large-9 medium-8 column-->
										</div><!-- End Article Main Row-->
									</article>
								</div><!-- END large-12-->
									<?php 
								}/*End If $distance <= $geo_radius_search */
							}/*End If $post_latitude */
						}else{ /*End If $post_location_search */
							$post_location = get_post_meta($post->ID, $locShownBy, true);
							//echo $post_location; exit();
							if($post_location == $post_location_search) {
								$current++; $current2++; $emptyPost2++;
								$post_latitude = get_post_meta($post->ID, 'post_latitude', true);
								$post_longitude = get_post_meta($post->ID, 'post_longitude', true);
								
								if(!empty($post_latitude)) { 
									global $redux_demo;
									$measure_system = $redux_demo['measure-system'];
									if(!empty($measure_system)) {
										if($measure_system == "1") {
											$distance = 3958.755864232 * acos(sin($post_latitude / 57.2958) * sin($geo_search_lat / 57.2958) +cos($post_latitude / 57.2958) * cos($geo_search_lat / 57.2958) *cos($geo_search_lng / 57.2958 - $post_longitude / 57.2958));	
										}else{
											$distance = 6371 * acos(sin($post_latitude / 57.2958) * sin($geo_search_lat / 57.2958) +cos($post_latitude / 57.2958) * cos($geo_search_lat / 57.2958) *cos($geo_search_lng / 57.2958 - $post_longitude / 57.2958));
										}
									}else{ /*End If !empty($measure_system */
										$distance = 6371 * acos(sin($post_latitude / 57.2958) * sin($geo_search_lat / 57.2958) +cos($post_latitude / 57.2958) * cos($geo_search_lat / 57.2958) *cos($geo_search_lng / 57.2958 - $post_longitude / 57.2958));
									}
									if( $distance <= $geo_radius_search ) {										
										?>
										<div class="large-12 medium-12 columns advItems end">
										<?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 = "";
												$postCatgory = get_the_category( $post->ID );
												$post_price = get_post_meta($post->ID, 'post_price', true);
												$comments_count = wp_count_comments( $post->ID  );
												$approvedComment = $comments_count->approved;
										/*Get Category Extra Fields For Price Icon Background */
										?>
										<article class="listAdv">
											<div class="row">
												<div class="large-3 medium-4 column">
													<div class="list-img">
														<?php if(!empty($post_price)){ ?>
														<span class="listPrice" style="background-color:<?php echo $category_icon_color; ?>"><?php echo $post_price; ?></span>
														<?php }?>
														<?php /*Start Image */
														if ( has_post_thumbnail()) {
																$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
																echo $thumbImg = get_the_post_thumbnail($post->ID, '270x220');
															}else{
																?>
																<img src="<?php echo get_template_directory_uri() . '/images/nothumb/nothumb270x250.png' ?>" alt="No Thumb"/>
																<?php
															}
													/*End Image */?>
														<div class="listcomment">
															<span><?php echo $approvedComment; ?></span>
															<i class="fa fa-comments"></i>
															<span><?php echo classiera_get_post_views($post->ID); ?></span>
															<i class="fa fa-eye"></i>
														</div>	<!-- End listcomment-->
													</div>
												</div><!-- End large-3 medium-4 column-->
												<div class="large-9 medium-8 column">
													<div class="listAdv-desc">
														<div class="row">
															<div class="large-6 medium-7 columns">
																<div class="listAdv-desc-header">
																	<div class="icon">
																		<i class="<?php echo $category_icon; ?>" style="background-color:<?php echo $category_icon_color; ?>"></i>
																		<h4><a href="<?php the_permalink(); ?>"><?php $theTitle = get_the_title(); $theTitle = (strlen($theTitle) > 25) ? substr($theTitle,0,25).'...' : $theTitle; echo $theTitle; ?></a></h4>
																		<span><?php esc_html_e( 'Category', 'classiera' ); ?> &nbsp;:&nbsp;<?php echo $postCatgory[0]->name; ?></span>
																	</div>
																</div>
															</div><!-- large-9-->
															<div class="large-6 medium-5 column">
															<?php if(function_exists('the_ratings')) { ?>
																<div class="rating">
																	<?php the_ratings(); ?>
																</div>
															<?php } ?>	
															</div><!-- large-3-->
														</div><!-- listAdv First Row-->
														<div class="row">
															<div class="large-12 columns">
																<div class="listAdv-desc-detail">
																	<?php echo substr(get_the_excerpt(), 0,260); ?>
																</div>
															</div>
														</div><!-- listAdv second Row-->
														<div class="row">
															<div class="listAdv-tags">
																<div class="large-6 medium-7 columns">
																	<div class="listTags">
																		<i class="fa fa-tags"></i>
																		<span><?php esc_html_e('Tags', 'classiera'); ?>:</span>
																		<?php the_tags('','',''); ?>
																	</div><!-- listTags-->
																</div><!-- large-6-->
																<div class="large-6 medium-5 columns">
																	<div class="listReadMore">
																		<a href="<?php the_permalink(); ?>">
																		<?php esc_html_e( 'Read More', 'classiera' ); ?>
																		</a>
																	</div>
																</div><!-- large-6 medium-5-->
															</div><!-- listAdv-tags-->
														</div><!-- listAdv third Row-->
													</div><!-- listAdv-desc-->
												</div><!-- large-9 medium-8 column-->
											</div><!-- End Article Main Row-->
										</article>
									</div><!-- END large-12-->
										<?php
									}/*End If $distance <= $geo_radius_search*/
								}/*End If !empty($post_latitude)) */
							}/*End If $post_location == $post_location_search */
						}
					}else{/*End If $geo_location */					
						if($post_location_search == 'All') {
							$current++; $current2++; $emptyPost2++;
							?>
							<div class="large-12 medium-12 columns advItems end">
								<?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 = "";
										$postCatgory = get_the_category( $post->ID );
										$post_price = get_post_meta($post->ID, 'post_price', true);
										$comments_count = wp_count_comments( $post->ID  );
										$approvedComment = $comments_count->approved;
								/*Get Category Extra Fields For Price Icon Background */
								?>
								<article class="listAdv">
									<div class="row">
										<div class="large-3 medium-4 column">
											<div class="list-img">
												<?php if(!empty($post_price)){ ?>
												<span class="listPrice" style="background-color:<?php echo $category_icon_color; ?>"><?php echo $post_price; ?></span>
												<?php }?>
												<?php /*Start Image */
												if ( has_post_thumbnail()) {
														$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
														echo $thumbImg = get_the_post_thumbnail($post->ID, '270x220');
													}else{
														?>
														<img src="<?php echo get_template_directory_uri() . '/images/nothumb/nothumb270x250.png' ?>" alt="No Thumb"/>
														<?php
													}
											/*End Image */?>
												<div class="listcomment">
													<span><?php echo $approvedComment; ?></span>
													<i class="fa fa-comments"></i>
													<span><?php echo classiera_get_post_views($post->ID); ?></span>
													<i class="fa fa-eye"></i>
												</div>	<!-- End listcomment-->
											</div>
										</div><!-- End large-3 medium-4 column-->
										<div class="large-9 medium-8 column">
											<div class="listAdv-desc">
												<div class="row">
													<div class="large-6 medium-7 columns">
														<div class="listAdv-desc-header">
															<div class="icon">
																<i class="<?php echo $category_icon; ?>" style="background-color:<?php echo $category_icon_color; ?>"></i>
																<h4><a href="<?php the_permalink(); ?>"><?php $theTitle = get_the_title(); $theTitle = (strlen($theTitle) > 25) ? substr($theTitle,0,25).'...' : $theTitle; echo $theTitle; ?></a></h4>
																<span><?php esc_html_e( 'Category', 'classiera' ); ?> &nbsp;:&nbsp;<?php echo $postCatgory[0]->name; ?></span>
															</div>
														</div>
													</div><!-- large-9-->
													<div class="large-6 medium-5 column">
													<?php if(function_exists('the_ratings')) { ?>
														<div class="rating">
															<?php the_ratings(); ?>
														</div>
													<?php } ?>	
													</div><!-- large-3-->
												</div><!-- listAdv First Row-->
												<div class="row">
													<div class="large-12 columns">
														<div class="listAdv-desc-detail">
															<?php echo substr(get_the_excerpt(), 0,260); ?>
														</div>
													</div>
												</div><!-- listAdv second Row-->
												<div class="row">
													<div class="listAdv-tags">
														<div class="large-6 medium-7 columns">
															<div class="listTags">
																<i class="fa fa-tags"></i>
																<span><?php esc_html_e('Tags', 'classiera'); ?>:</span>
																<?php the_tags('','',''); ?>
															</div><!-- listTags-->
														</div><!-- large-6-->
														<div class="large-6 medium-5 columns">
															<div class="listReadMore">
																<a href="<?php the_permalink(); ?>">
																<?php esc_html_e( 'Read More', 'classiera' ); ?>
																</a>
															</div>
														</div><!-- large-6 medium-5-->
													</div><!-- listAdv-tags-->
												</div><!-- listAdv third Row-->
											</div><!-- listAdv-desc-->
										</div><!-- large-9 medium-8 column-->
									</div><!-- End Article Main Row-->
								</article>
							</div><!-- END large-12-->
							<?php
						}else{/*$post_location_search == 'All */
							$post_location = get_post_meta($post->ID, $locShownBy, true); 
							if($post_location == $post_location_search) {
								$current++; $current2++; $emptyPost2++;
								?>
								<div class="large-12 medium-12 columns advItems end">
									<?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 = "";
											$postCatgory = get_the_category( $post->ID );
											$post_price = get_post_meta($post->ID, 'post_price', true);
											$comments_count = wp_count_comments( $post->ID  );
											$approvedComment = $comments_count->approved;
									/*Get Category Extra Fields For Price Icon Background */
									?>
									<article class="listAdv">
										<div class="row">
											<div class="large-3 medium-4 column">
												<div class="list-img">
													<?php if(!empty($post_price)){ ?>
													<span class="listPrice" style="background-color:<?php echo $category_icon_color; ?>"><?php echo $post_price; ?></span>
													<?php }?>
													<?php /*Start Image */
													if ( has_post_thumbnail()) {
															$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
															echo $thumbImg = get_the_post_thumbnail($post->ID, '270x220');
														}else{
															?>
															<img src="<?php echo get_template_directory_uri() . '/images/nothumb/nothumb270x250.png' ?>" alt="No Thumb"/>
															<?php
														}
												/*End Image */?>
													<div class="listcomment">
														<span><?php echo $approvedComment; ?></span>
														<i class="fa fa-comments"></i>
														<span><?php echo classiera_get_post_views($post->ID); ?></span>
														<i class="fa fa-eye"></i>
													</div>	<!-- End listcomment-->
												</div>
											</div><!-- End large-3 medium-4 column-->
											<div class="large-9 medium-8 column">
												<div class="listAdv-desc">
													<div class="row">
														<div class="large-6 medium-7 columns">
															<div class="listAdv-desc-header">
																<div class="icon">
																	<i class="<?php echo $category_icon; ?>" style="background-color:<?php echo $category_icon_color; ?>"></i>
																	<h4><a href="<?php the_permalink(); ?>"><?php $theTitle = get_the_title(); $theTitle = (strlen($theTitle) > 25) ? substr($theTitle,0,25).'...' : $theTitle; echo $theTitle; ?></a></h4>
																	<span><?php esc_html_e( 'Category', 'classiera' ); ?> &nbsp;:&nbsp;<?php echo $postCatgory[0]->name; ?></span>
																</div>
															</div>
														</div><!-- large-9-->
														<div class="large-6 medium-5 column">
														<?php if(function_exists('the_ratings')) { ?>
															<div class="rating">
																<?php the_ratings(); ?>
															</div>
														<?php } ?>	
														</div><!-- large-3-->
													</div><!-- listAdv First Row-->
													<div class="row">
														<div class="large-12 columns">
															<div class="listAdv-desc-detail">
																<?php echo substr(get_the_excerpt(), 0,260); ?>
															</div>
														</div>
													</div><!-- listAdv second Row-->
													<div class="row">
														<div class="listAdv-tags">
															<div class="large-6 medium-7 columns">
																<div class="listTags">
																	<i class="fa fa-tags"></i>
																	<span><?php esc_html_e('Tags', 'classiera'); ?>:</span>
																	<?php the_tags('','',''); ?>
																</div><!-- listTags-->
															</div><!-- large-6-->
															<div class="large-6 medium-5 columns">
																<div class="listReadMore">
																	<a href="<?php the_permalink(); ?>">
																	<?php esc_html_e( 'Read More', 'classiera' ); ?>
																	</a>
																</div>
															</div><!-- large-6 medium-5-->
														</div><!-- listAdv-tags-->
													</div><!-- listAdv third Row-->
												</div><!-- listAdv-desc-->
											</div><!-- large-9 medium-8 column-->
										</div><!-- End Article Main Row-->
									</article>
								</div><!-- END large-12-->

								<?php
							}/*$post_location == $post_location_search*/
						}
					}
				?>
				<?php endwhile; ?>
			</div><!-- END panel1-->
			<?php wp_reset_query(); ?>
		</div><!-- END tabs-content-->
		<?php if($emptyPost2 == 0) { ?>
			<div class="row">
				<div class="large-7 medium-8 large-centered medium-centered columns">
					<p><?php esc_html_e( 'No results found for the selected search criteria.', 'classiera' ); ?></p>
				</div>
			</div>
		<?php } ?>
	</div><!-- END Row-->
</section>
<?php get_footer(); ?>