I’m trying to customize a wp-plugin (wp job manager) so it could search on multiple keywords at once. Momently it only lets me find results based on a single keyword input like ‘wendy’ because the input in the post has ‘firstname=wendy’. I’m searching a way to configure to search something like a combination of words. Even if it’s not in the same input-query of the post itself. Example: ‘Wendy Vener’. When I try to search on ‘Wendy Vener’ it find nothing because there was no singular inputfield with the value ‘Wendy Vener’.
The code of the searchfield:
if ( ! function_exists( 'get_job_listings_keyword_search' ) ) :
/**
* Join and where query for keywords
*
* @param array $args
* @return array
*/
function get_job_listings_keyword_search( $args ) {
global $wpdb, $job_manager_keyword;
$conditions = array();
$conditions[] = "{$wpdb->posts}.post_title LIKE '%" . esc_sql( $job_manager_keyword ) . "%'";
$conditions[] = "{$wpdb->posts}.ID IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value LIKE '%" . esc_sql( $job_manager_keyword ) . "%' )";
if ( ctype_alnum( $job_manager_keyword ) ) {
$conditions[] = "{$wpdb->posts}.post_content RLIKE '[[:<:]]" . esc_sql( $job_manager_keyword ) . "[[:>:]]'";
} else {
$conditions[] = "{$wpdb->posts}.post_content LIKE '%" . esc_sql( $job_manager_keyword ) . "%'";
}
$args['where'] .= " AND ( " . implode( ' OR ', $conditions ) . " ) ";
return $args;
}
Thanks in advance!