Add_Custom_Fields_To_Search::cf_search_where( string $where )

cf_search_where


Description

Modify the search query with posts_where

See also


Parameters

$where

(string) (Required)


Return

(void)


Source

File: includes/class-add-custom-fields-to-search.php

		 * @see http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where
		 *
		 * @param  string $where
		 * @return string
		 */
		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 ) ",