Add_Custom_Fields_To_Search::cf_search_where( string $where )
Modify the search query with posts_where
On This Page
Description Description
See also See also
Parameters Parameters
- $where
-
(string) (Required)
Return Return
(string)
Source Source
File: includes/class-add-custom-fields-to-search.php
public function cf_search_where( $where ) {
if ( ! is_search() || $this->is_media_library() ) {
return $where;
}
global $wpdb;
$where = preg_replace(
"/\(\s*$wpdb->posts.post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
"($wpdb->posts.post_title LIKE $1) OR ( searchmeta.meta_value LIKE $1 ) ",
$where
);
return $where;
}
Expand full source codeCollapse full source codeView on Github