elagoon (April 15th, 2016)
add_action('pre_get_posts','add_region_function_51423');
function add_region_function_51423($query) {
$cp_zipcode = $_GET['cp_zipcode'];
$cp_city = $_GET['cp_city'];
if(!is_admin() && $query->is_main_query()) {
if($query->is_search()) {
if($_GET['cp_zipcode'] != "" || $_GET['cp_city'] != "" ) {
$meta_query = array(
'relation' => 'OR',
array(
'key' => 'cp_city',
'value' => $cp_city ,
'compare' => 'LIKE'
),
array(
'key' => 'cp_zipcode',
'value' =>$cp_zipcode,
'compare' => 'LIKE'
)
);
$query->set('meta_query',$meta_query);
}
}
}
}
elagoon (April 15th, 2016)
There are currently 1 users browsing this thread. (0 members and 1 guests)