Add_Custom_Fields_To_Search::cf_search_join( string $join )

Join posts and postmeta tables

Description Description

See also See also


Top ↑

Parameters Parameters

$join

(string) (Required) The JOIN clause of the query.


Top ↑

Return Return

(string)


Top ↑

Source Source

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

		public function cf_search_join( $join ) {
			global $wpdb;

			if ( ! is_search() || $this->is_media_library() ) {
				return $join;
			}

			// join to search post meta values like year, make, model, trim, etc.
			$join .= " LEFT JOIN $wpdb->postmeta searchmeta ON $wpdb->posts.ID = searchmeta.post_id ";
			return $join;
		}