<?php
function custom_ajax_search()
{
?>
<div class="search-bar">
<form action="<?php bloginfo('url'); ?>/" method="get" id="searchform" class="form_search">
<input name="s" type="text" id="ss" value="<?php _e('What are you looking for?','cp'); ?>" onfocus="if (this.value == '<?php _e('What are you looking for?','cp'); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e('What are you looking for?','cp'); ?>';}" class="editbox_search" /> in
<?php wp_dropdown_categories('show_option_all='.__('All Categories', 'cp').'&hierarchical=1&hide_empty=0&orderby=id&show_count=0&title_li=&use_desc_for_title=1&exclude_tree='.CP_BLOG_CAT_ID); ?> in
<input name="where" type="text" id="sss" value="<?php _e('City or State','cp'); ?>" onfocus="if (this.value == '<?php _e('City or State','cp'); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e('City or State','cp'); ?>';}" class="editbox_search" />
<input type="submit" class="btn_orange" value="<?php _e('Search','cp')?>" title="Search" id="go" name="sa" />
</form>
</div><!-- search-bar -->
<?php
}
function custom_ajax_search_css()
{
?>
<style type="text/css">
.search-bar{
width: 920px;
margin: 0 auto;
display: block;
background: #7DA741;
padding: 10px;
}
.search-bar .form_search input#ss {
border:1px solid #BBBBBB;
color:#4F4F4F;
padding:6px;
width: 218px;
}
.search-bar .form_search input#sss {
border:1px solid #BBBBBB;
color:#4F4F4F;
padding:6px;
width: 125px;
}
</style>
<?php
}
add_action('wp_head', 'custom_ajax_search_css');
function custom_search_where_city($where)
{
global $wpdb;
if (is_search() && isset($_GET['where'])) {
if( !empty($_GET['where']) )
{
$q = $wpdb->escape($_GET['where']);
$where = " AND ( ($wpdb->postmeta.meta_key = 'cp_state' AND $wpdb->postmeta.meta_value = '$q' ) OR ($wpdb->postmeta.meta_key = 'cp_city' AND $wpdb->postmeta.meta_value = '$q' ) )";
}
}
return $where;
}
add_filter('posts_where', 'custom_search_where_city');
?>
ahikmahin (November 20th, 2010)
ahikmahin (November 21st, 2010)
There are currently 1 users browsing this thread. (0 members and 1 guests)