add additional custom fields here to include them in search results
Hi there, i have modified my jobroller resume successfully and was wonder how to add the additional fields i added to the search header. I have found the following code below in theme-functions.php. I have tried to add the custom field to the options below but have had no sucess. would it be possible to pint me in the right direction please?
// search on custom fields
function custom_search_where($where) {
global $wpdb;
$old_where = $where;
if (is_search() && isset($_GET['s']) && !isset($_GET['resume_search'])) {
// add additional custom fields here to include them in search results
$customs = array('_Company', 'geo_address', '_CompanyURL', 'geo_short_address', 'geo_country', 'geo_short_address_country');
$query = '';
$var_q = stripslashes($_GET['s']);
preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $var_q, $matches);
$search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
$n = '%';
$searchand = '';
foreach((array)$search_terms as $term) {
$term = addslashes_gpc($term);
$query .= "{$searchand}(";
$query .= "($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')";
$query .= " OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')";
foreach($customs as $custom) {
$query .= " OR (";
$query .= "($wpdb->postmeta.meta_key = '$custom')";
$query .= " AND ($wpdb->postmeta.meta_value LIKE '{$n}{$term}{$n}')";
$query .= ")";
}
$query .= ")";
$searchand = ' AND ';
}
$term = $wpdb->escape($var_q);
$where .= " OR ($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')";
$where .= " OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')";
if (!empty($query)) {
$where = " AND ({$query}) AND ($wpdb->posts.post_status = 'publish') AND ($wpdb->posts.post_type = 'job_listing')";
}
} else if (is_search() && isset($_GET['s'])) {
// add additional custom fields here to include them in search results
$customs = array(
'_desired_position',
'_resume_websites',
'_experience',
'_education',
'_skills',
'_desired_salary',
'_email_address',
'geo_address',
'geo_country'
);
$query = '';
$var_q = stripslashes($_GET['s']);
preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $var_q, $matches);
$search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
Regards
Stephen