Add_Custom_Fields_To_Search::cf_search_where( string $where )

Modify the search query with posts_where

Description Description

See also See also


Top ↑

Parameters Parameters

$where

(string) (Required)


Top ↑

Return Return

(string)


Top ↑

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;
		}