Add_Custom_Fields_To_Search::cf_search_join( string $join )
Join posts and postmeta tables
Contents
Description Description
See also See also
Parameters Parameters
- $join
-
(string) (Required) The JOIN clause of the query.
Return Return
(string)
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 "; // these joins are so taxonomy terms like Sport Utility Vehicle => suv are included. $join .= "LEFT JOIN $wpdb->term_relationships tr ON $wpdb->posts.ID = tr.object_id " . "INNER JOIN $wpdb->term_taxonomy tt ON tt.term_taxonomy_id = tr.term_taxonomy_id " . "INNER JOIN $wpdb->terms t ON t.term_id = tt.term_id "; return $join; }
Expand full source code Collapse full source code View on Github