Add_Custom_Fields_To_Search::cf_search_where( string $where )

cf_search_where


Description Description

Modify the search query with posts_where

See also See also


Top ↑

Parameters Parameters

$where

(string) (Required)


Top ↑

Return Return

(void)


Top ↑

Source Source

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

		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) OR (t.name LIKE $1) OR (t.slug LIKE $1)",
				$where
			);

			return $where;
		}