Okay, how can I pass on regex as a search query to match titles only, when the query matches a specific word..
Currently, the search is happening across the title and content(custom fields), But wanted to limit to title for specific query.
add_action( WPSOLR_Events::WPSOLR_FILTER_UPDATE_WPSOLR_QUERY, 'update_query_existing', 10, 1 );
function update_query_existing( WPSOLR_Query $wpsolr_query ) {
if ( 'test' === $current_keywords ) {
if (preg_match('/^X-[a-zA-Z-]+/', $post_title)) { // checking if this condition matches, then return those results
return the posts matching the above regex;
}
}
}