Commit 990225d1 authored by Simonas's avatar Simonas

Awesomplete added

parent 16d6a5fa
......@@ -105,8 +105,12 @@ get_header(); ?>
if ( $searchQuery ) :
if ( $searchQuery['city'] && intval( $searchQuery['city'] ) ) :
$where = $where . ' AND city.term_id = ' . intval( $searchQuery['city'] );
if ( $searchQuery['city'] ) :
$city = get_term_by( 'name', $searchQuery['city'], 'city' );
if ( $city ) :
$where = $where . ' AND city.term_id = ' . $city->term_id;
endif;
endif;
if ( $searchQuery['s'] ) :
......
......@@ -8,7 +8,7 @@
* @version 1.0
*/
// global $searchPageURL;
global $query_string;
?>
<?php /*
......@@ -27,6 +27,11 @@
endwhile;
endif;
if ( is_search() ):
wp_parse_str( $query_string, $searchQuery );
endif;
?>
<datalist id="search-cities">
......@@ -46,7 +51,7 @@
foreach ( $cities as $city ):
$name = $city->name;
$termID = $city->term_id;
$selected = ($cityID == $termID) ? 'selected="selected"' : '';
// $selected = ($cityID == $termID) ? 'selected="selected"' : '';
$where = 'valid.meta_value > "' . date('Y-m-d', strtotime('-1 days')) . '" AND city.term_id = ' . $termID;
......@@ -60,14 +65,14 @@
if ( 0 < $jobsIn->total() ):
?>
<option value="<?php echo $termID; ?>" <?php echo $selected; ?>><?php echo $name; ?> (<?php echo $jobsIn->total(); ?>)</option>
<option value="<?php echo $name; ?>" <?php echo $selected; ?>><?php echo $name; ?> (<?php echo $jobsIn->total(); ?>)</option>
<?php
endif;
endforeach;
endif;
?>
</datalist>
<input list="search-cities" id="search-city" name="city" value="<?php echo cityID; ?>" placeholder="Vietovė" />
<input list="search-cities" id="search-city" name="city" value="<?php echo ($searchQuery) ? $searchQuery['city'] : ''; ?>" placeholder="Vietovė" />
<datalist id="search-queries">
<?php
......@@ -161,17 +166,12 @@
?>
</datalist>
<input list="search-queries" id="search-query" name="s" value="<?php echo searchQuery; ?>" placeholder="Raktažodis" />
<input list="search-queries" id="search-query" name="s" value="<?php echo ($searchQuery) ? $searchQuery['s'] : ''; ?>" placeholder="Raktažodis" />
<input type="submit" value="Ieškoti" class="filter-button" />
<?php
/*
<a href="<?php echo pll_home_url(); ?>" class="filter-button"><?php pll_e('Clear'); ?></a>
*/
?>
</form>
<?php
/*
......
......@@ -5,14 +5,18 @@ wp_parse_str( $query_string, $searchQuery );
if ( is_search() ) :
if ( $searchQuery['city'] && intval( $searchQuery['city'] ) && !$searchQuery['s'] ) :
$page = get_term_meta( $searchQuery['city'], 'page-id', true);
if ( $searchQuery['city'] && !$searchQuery['s'] ) :
$term = get_term_by( 'name', $searchQuery['city'], 'city' );
if ( $page ) :
if ( $term ) :
$page = get_term_meta( $term->term_id, 'page-id', true);
if ( $page ) :
?>
<link rel="canonical" href="<?php echo get_page_link( $page['ID'] ); ?>" />
<?php
return;
return;
endif;
endif;
elseif ( !$searchQuery['city'] && $searchQuery['s'] ) :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment